From d9afb5fc472a8321e67a6f36138f9d3784c9ac52 Mon Sep 17 00:00:00 2001 From: tping Date: Thu, 17 Jun 2021 17:17:51 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98=20?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=88=86=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php b/ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php index fbb0c4d8..78489be1 100644 --- a/ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php +++ b/ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php @@ -42,7 +42,11 @@ class Weixin //自定义订单号,此处仅作举例 $timeStamp = time(); - + + if (!isset($payConf['share']) || $payConf['share'] != 'N') { // 默认分账 + $unifiedOrder->setParameter("profit_sharing", 'Y');//分账 + } + $unifiedOrder->setParameter("out_trade_no", $order_no);//商户订单号 $unifiedOrder->setParameter("total_fee", $pay_amount * 100);//总金额 From e1cacaf94438b198c08deeb1109688624000293d Mon Sep 17 00:00:00 2001 From: tping Date: Fri, 18 Jun 2021 16:55:51 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=88=86=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/PayService.class.php | 4 ++++ Application/Sdk/Controller/BaseController.class.php | 3 +++ Application/Sdk/Controller/PayH5Controller.class.php | 6 ++++++ ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php | 3 ++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Application/Base/Service/PayService.class.php b/Application/Base/Service/PayService.class.php index 3f55dcfd..532d2fae 100644 --- a/Application/Base/Service/PayService.class.php +++ b/Application/Base/Service/PayService.class.php @@ -51,6 +51,10 @@ class PayService { Vendor("WxPayPubHelper.WxPayPubHelper"); $orderQuery = new \OrderQuery_pub($payConf['appid'], $payConf['partner'], $payConf['key']); $orderQuery->setParameter('out_trade_no', $orderInfo['out_trade_no']);//商户订单号 + + if (in_array($payConf['partner'], C('SHARE_ID'))) { + $orderQuery->setParameter("sub_mch_id", C('SHARE_PAIR.'.$payConf['partner']));// + } $result = $orderQuery->getResult(); Log::write("wechatQUERYFAIL->".serialize($result), Log::DEBUG); if($result['trade_state']=='SUCCESS') { diff --git a/Application/Sdk/Controller/BaseController.class.php b/Application/Sdk/Controller/BaseController.class.php index a32a9c12..0077ace1 100644 --- a/Application/Sdk/Controller/BaseController.class.php +++ b/Application/Sdk/Controller/BaseController.class.php @@ -590,6 +590,7 @@ class BaseController extends RestController $data_spned['merchant_id'] = isset($param['merchant_id']) ? $param['merchant_id'] : 0 ; $data_spned['merchant_way'] = isset($param['merchant_way']) ? $param['merchant_way'] : 0; $data_spned['partner_type'] = isset($param['main_id']) ? $param['main_id'] : 0; + $data_spned['share_status'] = isset($param['share_status']) ? $param['share_status'] : 0; return $data_spned; } @@ -627,6 +628,8 @@ class BaseController extends RestController $data_deposit['merchant_way'] = isset($param['merchant_way']) ? $param['merchant_way'] : 0; $data_deposit['partner_type'] = isset($param['main_id']) ? $param['main_id'] : 0; + $data_deposit['share_status'] = isset($param['share_status']) ? $param['share_status'] : 0; + return $data_deposit; } diff --git a/Application/Sdk/Controller/PayH5Controller.class.php b/Application/Sdk/Controller/PayH5Controller.class.php index 4a27baa2..d81321dc 100644 --- a/Application/Sdk/Controller/PayH5Controller.class.php +++ b/Application/Sdk/Controller/PayH5Controller.class.php @@ -764,6 +764,9 @@ class PayH5Controller extends BaseController{ $request['merchant_id'] = $pay_info['id']; $request['merchant_way'] = self::WX_PAY; $request['main_id'] = $main_id; + if (in_array($pay_conf['partner'], C('SHARE_ID'))) { + $request['share_status'] = 1; + } $this->add_deposit($request, 1); // .(is_ssl()?'https%3A%2F%2F':'http%3A%2F%2F'). $_SERVER ['HTTP_HOST'] . "%2Fsdk.php%2FSpend%2Fpay_success%2Forderno%2F".$request['pay_order_number'].'%2Fgame_id%2F'.$request['game_id'] ; /* if (I('request.api_ver') == 1) { @@ -1494,6 +1497,9 @@ class PayH5Controller extends BaseController{ $request['merchant_id'] = $pay_info['id']; $request['merchant_way'] = self::WX_PAY; $request['main_id'] = $main_id; + if (in_array($pay_conf['partner'], C('SHARE_ID'))) { + $request['share_status'] = 1; + } $this->add_spend($request,1); } diff --git a/ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php b/ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php index 78489be1..40d555ef 100644 --- a/ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php +++ b/ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php @@ -43,8 +43,9 @@ class Weixin $timeStamp = time(); - if (!isset($payConf['share']) || $payConf['share'] != 'N') { // 默认分账 + if (in_array($payConf['partner'], C('SHARE_ID'))) { $unifiedOrder->setParameter("profit_sharing", 'Y');//分账 + $unifiedOrder->setParameter("sub_mch_id", C('SHARE_PAIR.'.$payConf['partner']));// } $unifiedOrder->setParameter("out_trade_no", $order_no);//商户订单号 From 16eaa62ffdd6c2e4b2bba7ec1eebe74abb475060 Mon Sep 17 00:00:00 2001 From: tping Date: Wed, 23 Jun 2021 14:33:12 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=95=86=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/PayService.class.php | 6 +++--- .../Sdk/Controller/PayH5Controller.class.php | 10 +++++++--- ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php | 13 +++++-------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Application/Base/Service/PayService.class.php b/Application/Base/Service/PayService.class.php index 532d2fae..e4426038 100644 --- a/Application/Base/Service/PayService.class.php +++ b/Application/Base/Service/PayService.class.php @@ -52,14 +52,14 @@ class PayService { $orderQuery = new \OrderQuery_pub($payConf['appid'], $payConf['partner'], $payConf['key']); $orderQuery->setParameter('out_trade_no', $orderInfo['out_trade_no']);//商户订单号 - if (in_array($payConf['partner'], C('SHARE_ID'))) { - $orderQuery->setParameter("sub_mch_id", C('SHARE_PAIR.'.$payConf['partner']));// + if (C('SHARE_ID.'.$payConf['partner']) == 'y' || C('SHARE_ID.'.$payConf['partner']) == 'n') { + $orderQuery->setParameter("sub_mch_id", C('SHARE_PAIR.'.$payConf['partner'])); } $result = $orderQuery->getResult(); - Log::write("wechatQUERYFAIL->".serialize($result), Log::DEBUG); if($result['trade_state']=='SUCCESS') { return true; } + Log::write("wechatQUERYFAIL->".serialize($result), Log::DEBUG); return false; } diff --git a/Application/Sdk/Controller/PayH5Controller.class.php b/Application/Sdk/Controller/PayH5Controller.class.php index d81321dc..81813191 100644 --- a/Application/Sdk/Controller/PayH5Controller.class.php +++ b/Application/Sdk/Controller/PayH5Controller.class.php @@ -764,7 +764,7 @@ class PayH5Controller extends BaseController{ $request['merchant_id'] = $pay_info['id']; $request['merchant_way'] = self::WX_PAY; $request['main_id'] = $main_id; - if (in_array($pay_conf['partner'], C('SHARE_ID'))) { + if (C('SHARE_ID.'.$pay_conf['partner']) == 'y') { $request['share_status'] = 1; } $this->add_deposit($request, 1); @@ -775,6 +775,8 @@ class PayH5Controller extends BaseController{ } */ }else{ jsonOutput(0, "支付失败"); + Log::write("platform_weixin_pay支付失败".serialize($is_pay)); + exit(); // redirect(U('Spend/notice',array('user_id'=>$user_id, 'is_platform' => 1,'game_id'=>$game_id,'msg'=>'支付失败', 'user_token' => $this->userToken)));exit; } }elseif ($pay_info['channel'] == 5) { // 汇付宝 @@ -1497,7 +1499,7 @@ class PayH5Controller extends BaseController{ $request['merchant_id'] = $pay_info['id']; $request['merchant_way'] = self::WX_PAY; $request['main_id'] = $main_id; - if (in_array($pay_conf['partner'], C('SHARE_ID'))) { + if (C('SHARE_ID.'.$pay_conf['partner']) == 'y') { $request['share_status'] = 1; } $this->add_spend($request,1); @@ -1506,7 +1508,9 @@ class PayH5Controller extends BaseController{ // $json_data['url'] = $is_pay['mweb_url'].'&redirect_url='.C('PAY_DOMAIN')."sdk.php/Spend/paycallback/orderno/{$request['pay_order_number']}/game_id/{$request['game_id']}"; // (is_ssl()?'https%3A%2F%2F':'http%3A%2F%2F'). $_SERVER ['HTTP_HOST'] . "%2Fsdk.php%2FSpend%2Fpay_success%2Forderno%2F".$request['pay_order_number'].'%2Fgame_id%2F'.$request['game_id'] ; }else{ - echo json_encode(['code'=>0,'msg'=> '支付失败']);exit; + echo json_encode(['code'=>0,'msg'=> '支付失败']); + Log::write("platform_weixin_pay支付失败".serialize($is_pay)); + exit; // redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'支付失败', 'user_token' => $this->userToken)));exit; } }elseif ($pay_info['channel'] == 5) { diff --git a/ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php b/ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php index 40d555ef..d669f670 100644 --- a/ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php +++ b/ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php @@ -34,19 +34,16 @@ class Weixin $unifiedOrder = new \UnifiedOrder_pub(C('wei_xin_apps.email'), C('wei_xin_apps.partner'), C('wei_xin_apps.key')); } - - // $des='平台币充值'; - + $unifiedOrder->setParameter("body", $title);//商品描述 - - //自定义订单号,此处仅作举例 - - $timeStamp = time(); - if (in_array($payConf['partner'], C('SHARE_ID'))) { + if (C('SHARE_ID.'.$payConf['partner']) == 'y') { $unifiedOrder->setParameter("profit_sharing", 'Y');//分账 $unifiedOrder->setParameter("sub_mch_id", C('SHARE_PAIR.'.$payConf['partner']));// } + if (C('SHARE_ID.'.$payConf['partner']) == 'n') { + $unifiedOrder->setParameter("sub_mch_id", C('SHARE_PAIR.'.$payConf['partner']));// + } $unifiedOrder->setParameter("out_trade_no", $order_no);//商户订单号