From d8f943a05e46f0ae19eb2549db98e56953a4e611 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 13 Jul 2020 13:21:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=91=E8=8F=A0=E8=8F=9C?= =?UTF-8?q?=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/Notify2Controller.class.php | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/Application/Callback/Controller/Notify2Controller.class.php b/Application/Callback/Controller/Notify2Controller.class.php index 0706fc24..b36ddb3a 100644 --- a/Application/Callback/Controller/Notify2Controller.class.php +++ b/Application/Callback/Controller/Notify2Controller.class.php @@ -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; + } + /** * 支付宝退款回调