分销推广支付默认2倍
This commit is contained in:
parent
6586ce26af
commit
f0745812fc
@ -16,14 +16,20 @@ use app\common\model\Test;
|
||||
use app\common\server\WeChatPayServer;
|
||||
use app\common\server\WeChatServer;
|
||||
use app\common\model\integral\IntegralOrder;
|
||||
|
||||
use app\common\model\RechargeOrder;
|
||||
require_once ROOT_PATH . "/../vendor/hf/BsPayDemo/loader.php";
|
||||
require_once ROOT_PATH . "/../vendor/hf/BsPaySdk/init.php";
|
||||
use BsPaySdk\core\BsPay;
|
||||
use BsPaySdk\config\MerConfig;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
/**
|
||||
* Class Pay
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class Pay extends Api
|
||||
{
|
||||
public $like_not_need_login = ['notifyMnp1','notifyMnp', 'notifyOa', 'notifyApp', 'aliNotify', 'localPay', 'localBalance'];
|
||||
public $like_not_need_login = ['huifuNotify','notifyMnp1','notifyMnp', 'notifyOa', 'notifyApp', 'aliNotify', 'localPay', 'localBalance'];
|
||||
|
||||
/**
|
||||
* @notes 支付入口
|
||||
@ -38,6 +44,9 @@ class Pay extends Api
|
||||
{
|
||||
$user_id = $this->user_id;
|
||||
$post = $this->request->post();
|
||||
if ($post['from'] == 'recharge') {
|
||||
return $this->huifuCz($user_id, $post);
|
||||
}
|
||||
if(!isset($post['pay_way'])) {
|
||||
return JsonServer::error('请选择支付方式');
|
||||
}
|
||||
@ -113,6 +122,94 @@ class Pay extends Api
|
||||
return $result;
|
||||
|
||||
}
|
||||
public function huifuCz($user_id,$post)
|
||||
{
|
||||
$order = RechargeOrder::where([
|
||||
['id', '=', $post['order_id']]
|
||||
])->find();
|
||||
$user = Db::name("user_auth")->where("user_id",$user_id)->find();
|
||||
// $out = "dlh".time().$user_id;
|
||||
$config = new BsPay();
|
||||
$merConfig = $config->getConfig();
|
||||
// 2.组装请求参数
|
||||
$paramsInfo = array();
|
||||
// 请求日期
|
||||
$paramsInfo["req_date"] = date("Ymd");
|
||||
// 请求流水号
|
||||
$paramsInfo["req_seq_id"] = $order['order_sn'];
|
||||
// 商户号
|
||||
$paramsInfo["huifu_id"] = "6666000158818881";
|
||||
// 商品描述
|
||||
$paramsInfo["goods_desc"] = "充值";
|
||||
// 交易类型
|
||||
$paramsInfo["trade_type"] = "T_MINIAPP";
|
||||
// 交易金额
|
||||
$paramsInfo["trans_amt"] = $order['order_amount'];
|
||||
// 交易有效期
|
||||
$paramsInfo["time_expire"] = "20250518235959";
|
||||
// 微信参数集合
|
||||
$arr = array(
|
||||
"sub_appid"=>"wx586d77b9edb0636d",
|
||||
"sub_openid"=>$user['openid']
|
||||
);
|
||||
$paramsInfo["wx_data"] = json_encode($arr,true);
|
||||
// $paramsInfo["wx_data"] =
|
||||
// "{\"sub_appid\":\"wx586d77b9edb0636d\",\"sub_openid\":\"ouOMm4zEGaZbvNhq9PyoYN53902c\",
|
||||
// \"detail\":{\"cost_price\":\"43.00\",\"receipt_id\":\"20220628132043853798\",\"goods_detail\":
|
||||
// [{\"goods_id\":\"6934572310301\",\"goods_name\":\"太龙双黄连口服液\",\"price\":\"43.00\"
|
||||
// ,\"quantity\":\"1\",\"wxpay_goods_id\":\"12235413214070356458058\"}]}}";
|
||||
// 是否延迟交易
|
||||
$paramsInfo["delay_acct_flag"] = "N";
|
||||
// // 分账对象
|
||||
// $paramsInfo["acct_split_bunch"] = "{\"acct_infos\":[{\"div_amt\":\"0.10\",\"huifu_id\":\"6666000156739560\"}]}";
|
||||
// 传入分账遇到优惠的处理规则
|
||||
$paramsInfo["term_div_coupon_type"] = "0";
|
||||
// 禁用信用卡标记
|
||||
$paramsInfo["limit_pay_type"] = "NO_CREDIT";
|
||||
// 场景类型
|
||||
$paramsInfo["pay_scene"] = "02";
|
||||
// 备注
|
||||
$paramsInfo["remark"] = "string";
|
||||
// 异步通知地址
|
||||
$paramsInfo["notify_url"] = "https://dlh.hainings.com/api/pay/huifuNotify";
|
||||
// print_r("<pre>");
|
||||
// var_dump($paramsInfo);
|
||||
// 3. 发起API调用
|
||||
$bspay = new BsPay();
|
||||
$result = $bspay->post("v2.trade.payment.jspay", $paramsInfo, '', 'default');
|
||||
// var_dump($result);
|
||||
$result = $this->objectToArray($result);
|
||||
$rspDatas = $result['rspDatas']['data'];
|
||||
return JsonServer::success('操作成功', json_decode($rspDatas['pay_info'], true));
|
||||
}
|
||||
public function huifuNotify(){
|
||||
$result = $_REQUEST;
|
||||
// Log::write($result, '回调信息');
|
||||
if(isset($result['resp_code'])&&$result['resp_code']=="00000000"){
|
||||
$d['pay_status'] = 1;
|
||||
$d['pay_time'] = time();
|
||||
$d['pay_company'] = 3;
|
||||
$resp_data = json_decode($result['resp_data'],true);
|
||||
$d['transaction_id'] = $resp_data['out_trans_id'];
|
||||
$order = RechargeOrder::where([
|
||||
['order_sn', '=', $resp_data['req_seq_id']]
|
||||
])->update($d);
|
||||
}else{
|
||||
Log::write($result, '回调信息');
|
||||
}
|
||||
}
|
||||
private function objectToArray($object) {
|
||||
$reflectionClass = new \ReflectionClass($object);
|
||||
$properties = $reflectionClass->getProperties();
|
||||
$array = [];
|
||||
|
||||
foreach ($properties as $property) {
|
||||
$property->setAccessible(true);
|
||||
$array[$property->getName()] = $property->getValue($object);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
public function localPay()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user