|
|
|
@ -12,25 +12,25 @@ use Base\Service\PromoteService;
|
|
|
|
|
|
|
|
|
|
class Pay
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 支付驱动实例
|
|
|
|
|
* @var Object
|
|
|
|
|
*/
|
|
|
|
|
private $payer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 配置参数
|
|
|
|
|
* @var type
|
|
|
|
|
*/
|
|
|
|
|
private $config;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 支付类型
|
|
|
|
|
* @var type
|
|
|
|
|
*/
|
|
|
|
|
private $apitype;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构造方法,用于构造上传实例
|
|
|
|
|
* @param string $driver 要使用的支付驱动
|
|
|
|
@ -50,7 +50,7 @@ class Pay
|
|
|
|
|
$class = strpos($driver, '\\') ? $driver : 'Think\\Pay\\Driver\\' . ucfirst(strtolower($driver));
|
|
|
|
|
$this->setDriver($class, $config);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function isKBCPartner($promoteId)
|
|
|
|
|
{
|
|
|
|
|
$promote = null;
|
|
|
|
@ -66,26 +66,25 @@ class Pay
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function buildRequestForm(Pay\PayVo $vo, $uc = 0, $param=array())
|
|
|
|
|
|
|
|
|
|
public function buildRequestForm(Pay\PayVo $vo, $uc = 0, $param=array(), $payConf=array())
|
|
|
|
|
{
|
|
|
|
|
$promoteId = 0;
|
|
|
|
|
if ($vo->getPromoteId()) {
|
|
|
|
|
$promoteId = $vo->getPromoteId();
|
|
|
|
|
} elseif (isset($param['promote_id']) && $param['promote_id']) {
|
|
|
|
|
$promoteId = $param['promote_id'];
|
|
|
|
|
}
|
|
|
|
|
$isKBCPartner = $this->isKBCPartner($promoteId);
|
|
|
|
|
|
|
|
|
|
/* $promoteId = 0;
|
|
|
|
|
if ($vo->getPromoteId()) {
|
|
|
|
|
$promoteId = $vo->getPromoteId();
|
|
|
|
|
} elseif (isset($param['promote_id']) && $param['promote_id']) {
|
|
|
|
|
$promoteId = $param['promote_id'];
|
|
|
|
|
}
|
|
|
|
|
$isKBCPartner = $this->isKBCPartner($promoteId); */
|
|
|
|
|
$this->payer->check();
|
|
|
|
|
$result = false;
|
|
|
|
|
if ($uc == 0) {
|
|
|
|
|
switch ($vo->getTable()) {
|
|
|
|
|
case 'spend':
|
|
|
|
|
$result = $this->add_spend($vo, $param, $isKBCPartner);
|
|
|
|
|
$result = $this->add_spend($vo, $param, $payConf);
|
|
|
|
|
break;
|
|
|
|
|
case 'deposit':
|
|
|
|
|
$result = $this->add_deposit($vo, $isKBCPartner);
|
|
|
|
|
$result = $this->add_deposit($vo, $param, $payConf);
|
|
|
|
|
break;
|
|
|
|
|
case 'agent':
|
|
|
|
|
$result = $this->add_agent($vo);
|
|
|
|
@ -102,12 +101,12 @@ class Pay
|
|
|
|
|
case 'Withdraw':
|
|
|
|
|
$result=1;
|
|
|
|
|
break;
|
|
|
|
|
case 'order':{
|
|
|
|
|
$result = $this->add_order($vo);
|
|
|
|
|
};break;
|
|
|
|
|
case 'supersign' :
|
|
|
|
|
$result=1;
|
|
|
|
|
break;
|
|
|
|
|
case 'order':{
|
|
|
|
|
$result = $this->add_order($vo);
|
|
|
|
|
};break;
|
|
|
|
|
case 'supersign' :
|
|
|
|
|
$result=1;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
$result = false;
|
|
|
|
|
break;
|
|
|
|
@ -115,7 +114,7 @@ class Pay
|
|
|
|
|
if ($result !== false) {//$check !== false
|
|
|
|
|
if ($this->apitype == "alipay" && C('alipay.usenew')) {
|
|
|
|
|
if (C('alipay.appid')) {
|
|
|
|
|
return $this->newbuildRequestForm($vo, $isKBCPartner);
|
|
|
|
|
return $this->newbuildRequestForm($vo, $payConf);
|
|
|
|
|
} else {
|
|
|
|
|
E("appid未设置");
|
|
|
|
|
exit('新版appid未填写');
|
|
|
|
@ -129,28 +128,25 @@ class Pay
|
|
|
|
|
} else {
|
|
|
|
|
return $this->payer->buildRequestForm($vo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新版支付宝接口调用
|
|
|
|
|
* */
|
|
|
|
|
public function newbuildRequestForm(Pay\PayVo $vo, $isKBCPartner = false)
|
|
|
|
|
public function newbuildRequestForm(Pay\PayVo $vo, $payConf=array())
|
|
|
|
|
{
|
|
|
|
|
if (!$payConf) return false;
|
|
|
|
|
Vendor('Alipay.AopSdk');
|
|
|
|
|
$aop = new \AopClient();
|
|
|
|
|
$aop->appId = $isKBCPartner ? C('ALIPAY_KBC_APPID') : C('alipay.appid');
|
|
|
|
|
|
|
|
|
|
$aop->appId = $payConf['app_id'];
|
|
|
|
|
$aop->signType = 'RSA2';
|
|
|
|
|
$aop->rsaPrivateKey = $isKBCPartner ? C('ALIPAY_KBC_PRI') : C('alipay.pri_secret');
|
|
|
|
|
if (!$aop->rsaPrivateKey) {
|
|
|
|
|
$aop->rsaPrivateKey = file_get_contents("./Application/Sdk/SecretKey/alipay/rsa2_private_key.txt");
|
|
|
|
|
}
|
|
|
|
|
$aop->alipayrsaPublicKey = $isKBCPartner ? C('ALIPAY_KBC_PUB') : C('alipay.pub_secret');
|
|
|
|
|
if (!$aop->alipayrsaPublicKey) {
|
|
|
|
|
$aop->alipayrsaPublicKey = file_get_contents("./Application/Sdk/SecretKey/alipay/alipay2_public_key.txt");
|
|
|
|
|
}
|
|
|
|
|
$aop->rsaPrivateKey = $payConf['private_key'];
|
|
|
|
|
$aop->alipayrsaPublicKey = $payConf['public_key'];
|
|
|
|
|
|
|
|
|
|
$type = $vo->getPayMethod();
|
|
|
|
|
//file_put_contents(dirname(__FILE__) . '/newbuildRequestForm.txt',json_encode($vo->getOrderNo()));
|
|
|
|
|
//file_put_contents(dirname(__FILE__) . '/newbuildRequestForm.txt',json_encode($vo->getOrderNo()));
|
|
|
|
|
switch ($type) {
|
|
|
|
|
case 'direct':
|
|
|
|
|
$productcode = 'FAST_INSTANT_TRADE_PAY';
|
|
|
|
@ -168,29 +164,26 @@ class Pay
|
|
|
|
|
$request->setReturnUrl('http://' . $_SERVER ['HTTP_HOST'] . '/callback.php/Notify2/notify/apitype/alipay/methodtype/return_tb');
|
|
|
|
|
break;
|
|
|
|
|
case 'wap':
|
|
|
|
|
$returnurl = $vo->getCallback();
|
|
|
|
|
if (!$returnurl)
|
|
|
|
|
$returnurl = 'http://' . $_SERVER ['HTTP_HOST'] . "/sdk.php/Spend/pay_success";
|
|
|
|
|
$productcode = 'QUICK_WAP_PAY';
|
|
|
|
|
$request = new \AlipayTradeWapPayRequest();
|
|
|
|
|
$request->setReturnUrl($returnurl);
|
|
|
|
|
break;
|
|
|
|
|
case 'trade':
|
|
|
|
|
$returnurl = $vo->getCallback();
|
|
|
|
|
if (!$returnurl)
|
|
|
|
|
$returnurl = 'http://' . $_SERVER ['HTTP_HOST'] . "/sdk.php/Spend/pay_success";
|
|
|
|
|
$productcode = 'QUICK_WAP_PAY';
|
|
|
|
|
$request = new \AlipayTradeWapPayRequest();
|
|
|
|
|
$request->setReturnUrl($returnurl);
|
|
|
|
|
break;
|
|
|
|
|
case 'trade':
|
|
|
|
|
$productcode = 'QUICK_WAP_PAY';
|
|
|
|
|
$request = new \AlipayTradeWapPayRequest();
|
|
|
|
|
$request->setReturnUrl('http://' . $_SERVER ['HTTP_HOST'] . "/mobile.php/Trade/success");
|
|
|
|
|
break;
|
|
|
|
|
case 'mobile':
|
|
|
|
|
$aop->alipayrsaPublicKey = file_get_contents("./Application/Sdk/SecretKey/alipay/alipay2_public_key.txt");
|
|
|
|
|
$productcode = 'QUICK_MSECURITY_PAY';
|
|
|
|
|
$request = new \AlipayTradeAppPayRequest();
|
|
|
|
|
break;
|
|
|
|
|
case 'refund':
|
|
|
|
|
$aop->alipayrsaPublicKey = file_get_contents("./Application/Sdk/SecretKey/alipay/alipay2_public_key.txt");
|
|
|
|
|
$request = new \AlipayTradeRefundRequest();
|
|
|
|
|
break;
|
|
|
|
|
case 'transfer':
|
|
|
|
|
$aop->alipayrsaPublicKey = file_get_contents("./Application/Sdk/SecretKey/alipay/alipay2_public_key.txt");
|
|
|
|
|
$request = new \AlipayFundTransToaccountTransferRequest ();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
@ -200,137 +193,137 @@ class Pay
|
|
|
|
|
}
|
|
|
|
|
$notifyurl = $vo->getNotifyUrl();
|
|
|
|
|
if (!$notifyurl)
|
|
|
|
|
$notifyurl = 'http://' . $_SERVER ['HTTP_HOST'] . '/callback.php/Notify2/notify/apitype/alipay/methodtype/notify';
|
|
|
|
|
$request->setNotifyUrl($notifyurl);
|
|
|
|
|
|
|
|
|
|
switch ($type) {
|
|
|
|
|
case 'direct':
|
|
|
|
|
$request->setBizContent('{"product_code":"' . $productcode . '","body":"' . $vo->getBody() . '","subject":"' . $vo->getTitle() . '","total_amount":"' . $vo->getFee() . '","out_trade_no":"' . $vo->getOrderNo() . '"}');
|
|
|
|
|
return $aop->pageExecute($request, 'POST');
|
|
|
|
|
break;
|
|
|
|
|
case 'direct_dc':
|
|
|
|
|
$request->setBizContent('{"product_code":"' . $productcode . '","body":"' . $vo->getBody() . '","subject":"' . $vo->getTitle() . '","total_amount":"' . $vo->getFee() . '","out_trade_no":"' . $vo->getOrderNo() . '"}');
|
|
|
|
|
return $aop->pageExecute($request, 'POST');
|
|
|
|
|
break;
|
|
|
|
|
case 'direct_tb':
|
|
|
|
|
$request->setBizContent('{"product_code":"' . $productcode . '","body":"' . $vo->getBody() . '","subject":"' . $vo->getTitle() . '","total_amount":"' . $vo->getFee() . '","out_trade_no":"' . $vo->getOrderNo() . '"}');
|
|
|
|
|
return $aop->pageExecute($request, 'POST');
|
|
|
|
|
break;
|
|
|
|
|
case 'wap':
|
|
|
|
|
/*参数 out_trade_no:系统订单号*/
|
|
|
|
|
$request->setBizContent('{"product_code":"' . $productcode . '","body":"' . $vo->getBody() . '","subject":"' . $vo->getTitle() . '","total_amount":"' . $vo->getFee() . '","out_trade_no":"' . $vo->getOrderNo() . '"}');
|
|
|
|
|
return $aop->pageExecute($request, 'GET');
|
|
|
|
|
break;
|
|
|
|
|
case 'trade':
|
|
|
|
|
/*参数 out_trade_no:系统订单号*/
|
|
|
|
|
$request->setBizContent('{"product_code":"' . $productcode . '","body":"' . $vo->getBody() . '","subject":"' . $vo->getTitle() . '","total_amount":"' . $vo->getFee() . '","out_trade_no":"' . $vo->getOrderNo() . '"}');
|
|
|
|
|
return $aop->pageExecute($request, 'GET');
|
|
|
|
|
break;
|
|
|
|
|
case 'mobile':
|
|
|
|
|
/*参数 out_trade_no:系统订单号*/
|
|
|
|
|
$request->setBizContent('{"body":"' . $vo->getBody() . '","subject":"' . $vo->getTitle() . '","out_trade_no":"' . $vo->getOrderNo() . '","timeout_express":"30m","total_amount":"' . $vo->getFee() . '","product_code":"' . $productcode . '"}');
|
|
|
|
|
$response = $aop->sdkExecute($request);
|
|
|
|
|
$sHtml['arg'] = $response['orderstr'];
|
|
|
|
|
$sHtml['sign'] = $response['sign'];
|
|
|
|
|
$sHtml['out_trade_no'] = $vo->getOrderNo();
|
|
|
|
|
return $sHtml;
|
|
|
|
|
break;
|
|
|
|
|
case 'refund':
|
|
|
|
|
$batch_no = $vo->getBatchNo();
|
|
|
|
|
$map['batch_no'] = $batch_no;
|
|
|
|
|
$refund = M('refund_record', 'tab_')->where($map)->find();
|
|
|
|
|
/*参数 out_trade_no:系统订单号 trade_no:支付宝订单号 refund_amount:退款金额 out_request_no:退款请求号 refund_reason:退款原因*/
|
|
|
|
|
$request->setBizContent('{"out_trade_no":"","trade_no":"' . $vo->getOrderNo() . '","refund_amount":"' . $refund['pay_amount'] . '","out_request_no":"' . $batch_no . '","refund_reason":"调单"}');
|
|
|
|
|
$result = $aop->execute($request);
|
|
|
|
|
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
|
|
|
|
$resultCode = $result->$responseNode->code;
|
|
|
|
|
if (!empty($resultCode) && $resultCode == 10000) {
|
|
|
|
|
$date['tui_status'] = 1;
|
|
|
|
|
$date['tui_time'] = time();
|
|
|
|
|
M('refund_record', 'tab_')->where($map)->save($date);
|
|
|
|
|
$map_spend['pay_order_number'] = get_refund_pay_order_number($batch_no);
|
|
|
|
|
$spen_date['sub_status'] = 1;
|
|
|
|
|
$spen_date['settle_check'] = 1;
|
|
|
|
|
M('spend', 'tab_')->where($map_spend)->save($spen_date);
|
|
|
|
|
return "10000";//退款成功
|
|
|
|
|
} else {
|
|
|
|
|
return "退款失败";
|
|
|
|
|
}
|
|
|
|
|
case 'transfer':
|
|
|
|
|
$settlement_number = $vo->getOrderNo();
|
|
|
|
|
$WidthdrawNo = $vo->getBatchNo();
|
|
|
|
|
$map['settlement_number'] = $settlement_number;
|
|
|
|
|
$widthdraw = M('withdraw', 'tab_')->where($map)->find();
|
|
|
|
|
|
|
|
|
|
$promote = get_promote_entity($widthdraw['promote_id']);
|
|
|
|
|
/*参数 out_biz_no:打款单号 payee_type:账户类型 payee_account:支付账号 amount:转账金额 remark:备注*/
|
|
|
|
|
// var_dump('{"out_biz_no":"'.$WidthdrawNo.'","payee_type":"ALIPAY_LOGONID","payee_a1ccount":"'.$promote['alipay_account'].'","amount":"'.$widthdraw['sum_money'].'","payer_show_name":"","payee_real_name":"","remark":"'.$vo->getDetailData().'"}');exit;
|
|
|
|
|
|
|
|
|
|
$request->setBizContent('{"out_biz_no":"'.$WidthdrawNo.'","payee_type":"ALIPAY_LOGONID","payee_account":"'.$promote['alipay_account'].'","amount":"'.$widthdraw['sum_money'].'","payer_show_name":"","payee_real_name":"","remark":"'.$vo->getDetailData().'"}');
|
|
|
|
|
|
|
|
|
|
$result = $aop->execute($request);
|
|
|
|
|
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
|
|
|
|
$resultCode = $result->$responseNode->code;
|
|
|
|
|
$remark = date('Y-m-d H:i:s')." 提现单号:".$WidthdrawNo.", 提现";
|
|
|
|
|
if(!empty($resultCode)&&$resultCode == 10000){
|
|
|
|
|
$data['status'] = 1;
|
|
|
|
|
$data['end_time'] = time();
|
|
|
|
|
$data['widthdraw_number'] = $WidthdrawNo;
|
|
|
|
|
$data['tx_account'] = $promote['alipay_account'];
|
|
|
|
|
$data['respond'] = $remark."成功<br/>".$widthdraw['respond'];
|
|
|
|
|
M('withdraw', 'tab_')->where($map)->save($data);
|
|
|
|
|
$se_data['ti_status']=1;
|
|
|
|
|
M('settlement','tab_')->where($map)->save($se_data);
|
|
|
|
|
return "10000";//提现成功
|
|
|
|
|
} else {
|
|
|
|
|
$msg = $result->$responseNode->sub_msg;
|
|
|
|
|
$data['respond'] = $remark."失败:".$msg."<br/>".$widthdraw['respond'];
|
|
|
|
|
M('withdraw', 'tab_')->where($map)->save($data);
|
|
|
|
|
return $msg;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$notifyurl = 'http://' . $_SERVER ['HTTP_HOST'] . '/callback.php/Notify2/notify/apitype/alipay/methodtype/notify';
|
|
|
|
|
$request->setNotifyUrl($notifyurl);
|
|
|
|
|
|
|
|
|
|
switch ($type) {
|
|
|
|
|
case 'direct':
|
|
|
|
|
$request->setBizContent('{"product_code":"' . $productcode . '","body":"' . $vo->getBody() . '","subject":"' . $vo->getTitle() . '","total_amount":"' . $vo->getFee() . '","out_trade_no":"' . $vo->getOrderNo() . '"}');
|
|
|
|
|
return $aop->pageExecute($request, 'POST');
|
|
|
|
|
break;
|
|
|
|
|
case 'direct_dc':
|
|
|
|
|
$request->setBizContent('{"product_code":"' . $productcode . '","body":"' . $vo->getBody() . '","subject":"' . $vo->getTitle() . '","total_amount":"' . $vo->getFee() . '","out_trade_no":"' . $vo->getOrderNo() . '"}');
|
|
|
|
|
return $aop->pageExecute($request, 'POST');
|
|
|
|
|
break;
|
|
|
|
|
case 'direct_tb':
|
|
|
|
|
$request->setBizContent('{"product_code":"' . $productcode . '","body":"' . $vo->getBody() . '","subject":"' . $vo->getTitle() . '","total_amount":"' . $vo->getFee() . '","out_trade_no":"' . $vo->getOrderNo() . '"}');
|
|
|
|
|
return $aop->pageExecute($request, 'POST');
|
|
|
|
|
break;
|
|
|
|
|
case 'wap':
|
|
|
|
|
/*参数 out_trade_no:系统订单号*/
|
|
|
|
|
$request->setBizContent('{"product_code":"' . $productcode . '","body":"' . $vo->getBody() . '","subject":"' . $vo->getTitle() . '","total_amount":"' . $vo->getFee() . '","out_trade_no":"' . $vo->getOrderNo() . '"}');
|
|
|
|
|
return $aop->pageExecute($request, 'GET');
|
|
|
|
|
break;
|
|
|
|
|
case 'trade':
|
|
|
|
|
/*参数 out_trade_no:系统订单号*/
|
|
|
|
|
$request->setBizContent('{"product_code":"' . $productcode . '","body":"' . $vo->getBody() . '","subject":"' . $vo->getTitle() . '","total_amount":"' . $vo->getFee() . '","out_trade_no":"' . $vo->getOrderNo() . '"}');
|
|
|
|
|
return $aop->pageExecute($request, 'GET');
|
|
|
|
|
break;
|
|
|
|
|
case 'mobile':
|
|
|
|
|
/*参数 out_trade_no:系统订单号*/
|
|
|
|
|
$request->setBizContent('{"body":"' . $vo->getBody() . '","subject":"' . $vo->getTitle() . '","out_trade_no":"' . $vo->getOrderNo() . '","timeout_express":"30m","total_amount":"' . $vo->getFee() . '","product_code":"' . $productcode . '"}');
|
|
|
|
|
$response = $aop->sdkExecute($request);
|
|
|
|
|
$sHtml['arg'] = $response['orderstr'];
|
|
|
|
|
$sHtml['sign'] = $response['sign'];
|
|
|
|
|
$sHtml['out_trade_no'] = $vo->getOrderNo();
|
|
|
|
|
return $sHtml;
|
|
|
|
|
break;
|
|
|
|
|
case 'refund':
|
|
|
|
|
$batch_no = $vo->getBatchNo();
|
|
|
|
|
$map['batch_no'] = $batch_no;
|
|
|
|
|
$refund = M('refund_record', 'tab_')->where($map)->find();
|
|
|
|
|
/*参数 out_trade_no:系统订单号 trade_no:支付宝订单号 refund_amount:退款金额 out_request_no:退款请求号 refund_reason:退款原因*/
|
|
|
|
|
$request->setBizContent('{"out_trade_no":"","trade_no":"' . $vo->getOrderNo() . '","refund_amount":"' . $refund['pay_amount'] . '","out_request_no":"' . $batch_no . '","refund_reason":"调单"}');
|
|
|
|
|
$result = $aop->execute($request);
|
|
|
|
|
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
|
|
|
|
$resultCode = $result->$responseNode->code;
|
|
|
|
|
if (!empty($resultCode) && $resultCode == 10000) {
|
|
|
|
|
$date['tui_status'] = 1;
|
|
|
|
|
$date['tui_time'] = time();
|
|
|
|
|
M('refund_record', 'tab_')->where($map)->save($date);
|
|
|
|
|
$map_spend['pay_order_number'] = get_refund_pay_order_number($batch_no);
|
|
|
|
|
$spen_date['sub_status'] = 1;
|
|
|
|
|
$spen_date['settle_check'] = 1;
|
|
|
|
|
M('spend', 'tab_')->where($map_spend)->save($spen_date);
|
|
|
|
|
return "10000";//退款成功
|
|
|
|
|
} else {
|
|
|
|
|
return "退款失败";
|
|
|
|
|
}
|
|
|
|
|
case 'transfer':
|
|
|
|
|
$settlement_number = $vo->getOrderNo();
|
|
|
|
|
$WidthdrawNo = $vo->getBatchNo();
|
|
|
|
|
$map['settlement_number'] = $settlement_number;
|
|
|
|
|
$widthdraw = M('withdraw', 'tab_')->where($map)->find();
|
|
|
|
|
|
|
|
|
|
$promote = get_promote_entity($widthdraw['promote_id']);
|
|
|
|
|
/*参数 out_biz_no:打款单号 payee_type:账户类型 payee_account:支付账号 amount:转账金额 remark:备注*/
|
|
|
|
|
// var_dump('{"out_biz_no":"'.$WidthdrawNo.'","payee_type":"ALIPAY_LOGONID","payee_a1ccount":"'.$promote['alipay_account'].'","amount":"'.$widthdraw['sum_money'].'","payer_show_name":"","payee_real_name":"","remark":"'.$vo->getDetailData().'"}');exit;
|
|
|
|
|
|
|
|
|
|
$request->setBizContent('{"out_biz_no":"'.$WidthdrawNo.'","payee_type":"ALIPAY_LOGONID","payee_account":"'.$promote['alipay_account'].'","amount":"'.$widthdraw['sum_money'].'","payer_show_name":"","payee_real_name":"","remark":"'.$vo->getDetailData().'"}');
|
|
|
|
|
|
|
|
|
|
$result = $aop->execute($request);
|
|
|
|
|
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
|
|
|
|
$resultCode = $result->$responseNode->code;
|
|
|
|
|
$remark = date('Y-m-d H:i:s')." 提现单号:".$WidthdrawNo.", 提现";
|
|
|
|
|
if(!empty($resultCode)&&$resultCode == 10000){
|
|
|
|
|
$data['status'] = 1;
|
|
|
|
|
$data['end_time'] = time();
|
|
|
|
|
$data['widthdraw_number'] = $WidthdrawNo;
|
|
|
|
|
$data['tx_account'] = $promote['alipay_account'];
|
|
|
|
|
$data['respond'] = $remark."成功<br/>".$widthdraw['respond'];
|
|
|
|
|
M('withdraw', 'tab_')->where($map)->save($data);
|
|
|
|
|
$se_data['ti_status']=1;
|
|
|
|
|
M('settlement','tab_')->where($map)->save($se_data);
|
|
|
|
|
return "10000";//提现成功
|
|
|
|
|
} else {
|
|
|
|
|
$msg = $result->$responseNode->sub_msg;
|
|
|
|
|
$data['respond'] = $remark."失败:".$msg."<br/>".$widthdraw['respond'];
|
|
|
|
|
M('withdraw', 'tab_')->where($map)->save($data);
|
|
|
|
|
return $msg;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 商品订单表添加数据
|
|
|
|
|
* @param PayVo $vo
|
|
|
|
|
* @author 鹿文学
|
|
|
|
|
*/
|
|
|
|
|
private function add_order(Pay\PayVo $vo) {
|
|
|
|
|
$order=M('order','tab_');
|
|
|
|
|
|
|
|
|
|
$da = $order->where(['merchandise_id'=>$vo->getParam(),'buyer_id'=>$vo->getBuyerId()])->find();
|
|
|
|
|
if(is_array($da)) {
|
|
|
|
|
if($da['pay_status']==1) {return false;}
|
|
|
|
|
$vo->setOrderNo($da['order_number']);
|
|
|
|
|
return $da['id'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$order_data['order_number']=$vo->getOrderNo();
|
|
|
|
|
$order_data['buyer_id']=$vo->getBuyerId();
|
|
|
|
|
$order_data['buyer_account']=$vo->getBuyerAccount();
|
|
|
|
|
$order_data['seller_id']=$vo->getSellerId();
|
|
|
|
|
$order_data['seller_account']=$vo->getSellerAccount();
|
|
|
|
|
$order_data['seller_account']=$vo->getSellerAccount();
|
|
|
|
|
$order_data['order_small_id']=$vo->getSmallId();
|
|
|
|
|
$order_data['order_small_account']=$vo->getSmallAccount();
|
|
|
|
|
$order_data['merchandise_id']=$vo->getParam();
|
|
|
|
|
$order_data['order_price']=$vo->getFee();
|
|
|
|
|
$order_data['poundage']=$vo->getPoundage();
|
|
|
|
|
$order_data['real_money']=$vo->getMoney();
|
|
|
|
|
$order_data['pay_way'] = $vo->getPayWay();
|
|
|
|
|
$order_data['order_time'] = NOW_TIME;
|
|
|
|
|
$order_data['pay_status'] = 0;
|
|
|
|
|
$order_data['game_id'] = $vo->getGameId();
|
|
|
|
|
|
|
|
|
|
$result = $order->add($order_data);
|
|
|
|
|
return $result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 商品订单表添加数据
|
|
|
|
|
* @param PayVo $vo
|
|
|
|
|
* @author 鹿文学
|
|
|
|
|
*/
|
|
|
|
|
private function add_order(Pay\PayVo $vo) {
|
|
|
|
|
$order=M('order','tab_');
|
|
|
|
|
|
|
|
|
|
$da = $order->where(['merchandise_id'=>$vo->getParam(),'buyer_id'=>$vo->getBuyerId()])->find();
|
|
|
|
|
if(is_array($da)) {
|
|
|
|
|
if($da['pay_status']==1) {return false;}
|
|
|
|
|
$vo->setOrderNo($da['order_number']);
|
|
|
|
|
return $da['id'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$order_data['order_number']=$vo->getOrderNo();
|
|
|
|
|
$order_data['buyer_id']=$vo->getBuyerId();
|
|
|
|
|
$order_data['buyer_account']=$vo->getBuyerAccount();
|
|
|
|
|
$order_data['seller_id']=$vo->getSellerId();
|
|
|
|
|
$order_data['seller_account']=$vo->getSellerAccount();
|
|
|
|
|
$order_data['seller_account']=$vo->getSellerAccount();
|
|
|
|
|
$order_data['order_small_id']=$vo->getSmallId();
|
|
|
|
|
$order_data['order_small_account']=$vo->getSmallAccount();
|
|
|
|
|
$order_data['merchandise_id']=$vo->getParam();
|
|
|
|
|
$order_data['order_price']=$vo->getFee();
|
|
|
|
|
$order_data['poundage']=$vo->getPoundage();
|
|
|
|
|
$order_data['real_money']=$vo->getMoney();
|
|
|
|
|
$order_data['pay_way'] = $vo->getPayWay();
|
|
|
|
|
$order_data['order_time'] = NOW_TIME;
|
|
|
|
|
$order_data['pay_status'] = 0;
|
|
|
|
|
$order_data['game_id'] = $vo->getGameId();
|
|
|
|
|
|
|
|
|
|
$result = $order->add($order_data);
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getMarketAdminId($promoteId)
|
|
|
|
|
{
|
|
|
|
|
$promote = M('promote', 'tab_')->field(['id', 'chain', 'level', 'admin_id'])->where(['id' => $promoteId])->find();
|
|
|
|
@ -341,11 +334,11 @@ class Pay
|
|
|
|
|
}
|
|
|
|
|
return $marketAdminId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*消费表添加数据
|
|
|
|
|
*/
|
|
|
|
|
private function add_spend(Pay\PayVo $vo, $param=array(), $isKBCPartner = false)
|
|
|
|
|
private function add_spend(Pay\PayVo $vo, $param=array(), $payConf = array())
|
|
|
|
|
{
|
|
|
|
|
$spend = M("spend", "tab_");
|
|
|
|
|
$spend_data['user_id'] = $vo->getUserId();
|
|
|
|
@ -378,25 +371,27 @@ class Pay
|
|
|
|
|
$spend_data['spend_ip'] = get_client_ip();
|
|
|
|
|
$spend_data['sdk_version'] = $vo->getSdkVersion();
|
|
|
|
|
$spend_data['market_admin_id'] = $this->getMarketAdminId($vo->getPromoteId());
|
|
|
|
|
if ($isKBCPartner) {
|
|
|
|
|
$spend_data['partner_type'] = 1;
|
|
|
|
|
}
|
|
|
|
|
/* if ($isKBCPartner) {
|
|
|
|
|
$spend_data['partner_type'] = 1;
|
|
|
|
|
} */
|
|
|
|
|
if($vo->getSmallId() != $vo->getUserId()) {
|
|
|
|
|
$spend_data['small_id'] = $vo->getSmallId();
|
|
|
|
|
$spend_data['small_account'] = $vo->getSmallAccount();
|
|
|
|
|
}
|
|
|
|
|
if ($param) {
|
|
|
|
|
$spend_data['deduction_amount'] = $param['deduction_amount'];
|
|
|
|
|
$spend_data['discount_amount'] = $param['discount_amount'];
|
|
|
|
|
$spend_data['deduction_amount'] = $param['deduction_amount'];
|
|
|
|
|
$spend_data['discount_amount'] = $param['discount_amount'];
|
|
|
|
|
}
|
|
|
|
|
$spend_data['merchant_id'] = isset($payConf['merchant_id']) ? $payConf['merchant_id'] : 0;
|
|
|
|
|
$spend_data['merchant_way'] = isset($payConf['merchant_way']) ? $payConf['merchant_way'] : 0;
|
|
|
|
|
$result = $spend->add($spend_data);
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*平台币充值记录
|
|
|
|
|
*/
|
|
|
|
|
private function add_deposit(Pay\PayVo $vo, $isKBCPartner = false)
|
|
|
|
|
private function add_deposit(Pay\PayVo $vo, $param=array(), $payConf=array())
|
|
|
|
|
{
|
|
|
|
|
if (!empty($vo->getUc())) {
|
|
|
|
|
$uc = new Ucservice();
|
|
|
|
@ -423,14 +418,17 @@ class Pay
|
|
|
|
|
$deposit_data['create_time'] = NOW_TIME;
|
|
|
|
|
$deposit_data['sdk_version'] = $vo->getSdkVersion();
|
|
|
|
|
$deposit_data['market_admin_id'] = $this->getMarketAdminId($vo->getPromoteId());
|
|
|
|
|
if ($isKBCPartner) {
|
|
|
|
|
$deposit_data['partner_type'] = 1;
|
|
|
|
|
}
|
|
|
|
|
/* if ($isKBCPartner) {
|
|
|
|
|
$deposit_data['partner_type'] = 1;
|
|
|
|
|
} */
|
|
|
|
|
$deposit_data['merchant_id'] = isset($payConf['merchant_id']) ? $payConf['merchant_id'] : 0;
|
|
|
|
|
$deposit_data['merchant_way'] = isset($payConf['merchant_way']) ? $payConf['merchant_way'] : 0;
|
|
|
|
|
|
|
|
|
|
$result = $deposit->add($deposit_data);
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*添加代充记录 支付宝 /威富通
|
|
|
|
|
*/
|
|
|
|
@ -459,7 +457,7 @@ class Pay
|
|
|
|
|
$result = $agent->add();
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @函数或方法说明
|
|
|
|
|
* @支付宝查询订单信息
|
|
|
|
@ -484,17 +482,17 @@ class Pay
|
|
|
|
|
$data['trade_no'] = $order_no;
|
|
|
|
|
$request->setBizContent(json_encode($data));
|
|
|
|
|
$result = $aop->execute ($request);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$resultCode = $result->$responseNode->code;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!empty($resultCode)&&$resultCode == 10000){
|
|
|
|
|
return $result->$responseNode->total_amount;
|
|
|
|
|
} else {
|
|
|
|
|
return $result->$responseNode->sub_msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 绑币充值记录
|
|
|
|
@ -527,8 +525,8 @@ class Pay
|
|
|
|
|
$result = $agent->add();
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function add_balance(Pay\PayVo $vo) {
|
|
|
|
|
|
|
|
|
|
private function add_balance(Pay\PayVo $vo) {
|
|
|
|
|
$balance = M("balance", "tab_");
|
|
|
|
|
$balance_data['order_number'] = "";
|
|
|
|
|
$balance_data['pay_order_number'] = $vo->getOrderNo();
|
|
|
|
@ -545,7 +543,7 @@ class Pay
|
|
|
|
|
$result = $balance->add();
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设置支付驱动
|
|
|
|
|
* @param string $class 驱动类名称
|
|
|
|
@ -557,7 +555,7 @@ class Pay
|
|
|
|
|
E("不存在支付驱动:{$class}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function __call($method, $arguments)
|
|
|
|
|
{
|
|
|
|
|
if (method_exists($this, $method)) {
|
|
|
|
@ -566,5 +564,5 @@ class Pay
|
|
|
|
|
return call_user_func_array(array(&$this->payer, $method), $arguments);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|