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