|
|
|
@ -41,10 +41,12 @@ class Notify2Controller extends BaseController
|
|
|
|
|
Vendor('Alipay.AopSdk');
|
|
|
|
|
$aop = new \AopClient();
|
|
|
|
|
|
|
|
|
|
$rsaPath = $this->checkAliPartner($notify['out_trade_no']);
|
|
|
|
|
|
|
|
|
|
// $aop->alipayrsaPublicKey = file_get_contents("./Application/Sdk/SecretKey/alipay/alipay2_public_key.txt");
|
|
|
|
|
$aop->alipayrsaPublicKey = C('alipay.pub_secret');
|
|
|
|
|
if (!$aop->alipayrsaPublicKey) {
|
|
|
|
|
$aop->alipayrsaPublicKey = file_get_contents("./Application/Sdk/SecretKey/alipay/alipay2_public_key.txt");
|
|
|
|
|
$aop->alipayrsaPublicKey = file_get_contents("./Application/Sdk/SecretKey/" . $rsaPath . "/alipay2_public_key.txt");
|
|
|
|
|
}
|
|
|
|
|
$result = $aop->rsaCheckV1($notify,'','RSA2');
|
|
|
|
|
if ($result) {
|
|
|
|
@ -96,6 +98,55 @@ class Notify2Controller extends BaseController
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function checkAliPartner($orderNo)
|
|
|
|
|
{
|
|
|
|
|
$prefix = substr($orderNo, 0, 2);
|
|
|
|
|
$result = false;
|
|
|
|
|
$promoteId = 0;
|
|
|
|
|
switch ($prefix) {
|
|
|
|
|
case 'SP':
|
|
|
|
|
$promoteId = M('spend', 'tab_')->where(['pay_order_number' => $orderNo])->getField('promote_id');
|
|
|
|
|
break;
|
|
|
|
|
case 'PF':
|
|
|
|
|
$promoteId = M('deposit', 'tab_')->where(['pay_order_number' => $orderNo])->getField('promote_id');
|
|
|
|
|
break;
|
|
|
|
|
case 'AG':
|
|
|
|
|
$promoteId = M('agent', 'tab_')->where(['pay_order_number' => $orderNo])->getField('promote_id');
|
|
|
|
|
break;
|
|
|
|
|
case 'BR':
|
|
|
|
|
$promoteId = M('bind_recharge', 'tab_')->where(['pay_order_number' => $orderNo])->getField('promote_id');
|
|
|
|
|
break;
|
|
|
|
|
case 'TB':
|
|
|
|
|
$promoteId = M('balance', 'tab_')->where(['pay_order_number' => $orderNo])->getField('promote_id');
|
|
|
|
|
break;
|
|
|
|
|
case 'SI':
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if ($this->isKBCPartner($promoteId)) {
|
|
|
|
|
return 'kingbocai';
|
|
|
|
|
} else {
|
|
|
|
|
return 'alipay';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function isKBCPartner($promoteId)
|
|
|
|
|
{
|
|
|
|
|
$promote = null;
|
|
|
|
|
$company = null;
|
|
|
|
|
if ($promoteId) {
|
|
|
|
|
$promote = M('promote', 'tab_')->field(['company_id', 'id'])->where(['id' => $promoteId])->find();
|
|
|
|
|
}
|
|
|
|
|
if ($promote) {
|
|
|
|
|
$company = M('promote_company', 'tab_')->field(['ali_partner', 'id'])->where(['id' => $promote['compnay_id']])->find();
|
|
|
|
|
}
|
|
|
|
|
if ($company && $company['ali_partner'] == 1) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 支付宝退款回调
|
|
|
|
|