diff --git a/Application/Base/Service/PayService.class.php b/Application/Base/Service/PayService.class.php index 3f55dcfd..e4426038 100644 --- a/Application/Base/Service/PayService.class.php +++ b/Application/Base/Service/PayService.class.php @@ -51,11 +51,15 @@ 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 (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/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..81813191 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 (C('SHARE_ID.'.$pay_conf['partner']) == 'y') { + $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) { @@ -772,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) { // 汇付宝 @@ -1494,13 +1499,18 @@ class PayH5Controller extends BaseController{ $request['merchant_id'] = $pay_info['id']; $request['merchant_way'] = self::WX_PAY; $request['main_id'] = $main_id; + if (C('SHARE_ID.'.$pay_conf['partner']) == 'y') { + $request['share_status'] = 1; + } $this->add_spend($request,1); } // $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 fbb0c4d8..d669f670 100644 --- a/ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php +++ b/ThinkPHP/Library/Org/WeixinSDK/Weixin.class.php @@ -34,15 +34,17 @@ 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 (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);//商户订单号 $unifiedOrder->setParameter("total_fee", $pay_amount * 100);//总金额