From 2fc8ff51fb949a94b80eb32285607030780d5e62 Mon Sep 17 00:00:00 2001 From: xucong <850806214@qq.com> Date: Wed, 13 Nov 2024 23:30:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=94=80=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Pay.php | 3 ++- app/api/logic/PayLogic.php | 22 ++++++++++++++++++++++ app/common/logic/PayNotifyLogic.php | 13 ++++++++++++- app/common/server/WeChatPayServer.php | 2 +- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/app/api/controller/Pay.php b/app/api/controller/Pay.php index b56621aa..da7532d5 100755 --- a/app/api/controller/Pay.php +++ b/app/api/controller/Pay.php @@ -143,7 +143,8 @@ class Pay extends Api }else{ $client = 1; } - $result = PayLogic::distributionPay($user_id,$post, $client); + $result = PayLogic::distributionPay($user_id,$post,$client); +// $result = PayLogic::abc($user_id,$post); return $result; } diff --git a/app/api/logic/PayLogic.php b/app/api/logic/PayLogic.php index 587b015f..e39a7cfc 100755 --- a/app/api/logic/PayLogic.php +++ b/app/api/logic/PayLogic.php @@ -658,6 +658,28 @@ class PayLogic extends Logic } return JsonServer::success('微信支付发起成功', $res, 1); } + public static function abc($user_id,$post){ + $publicKey = " + -----BEGIN PUBLIC KEY----- + MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwRUsPpbQPhBWrxFhG00k9VBgnHc7dCZyTQYIZ0efDEZOPHtDfbldfBDlfZglvfUsVuxea4NffzkbCm9pakoQilSy7hioiF8sxhUYxpwFIbx15KaQsjpeCtu5yOr3bKb5qZNzf+QtL70EDPfdVdZ5mBlO7CMa01W7CtqkxBlc4iSfVeavFK7rzOJpTAoamHdcdjtffYlNAsg2q3I1SDIUkiasVCo+BtNgzLY+7y1mSt9SbXO5nCMBT9DQVqsccBHu4SYS6kExISfLDjfeAldgtNtMuuyESiyp53EEk/Xe8JzrrjnHloHB63H47TxElsApAEmz0dabJyMBqT8Ow/m5OQIDAQAB + -----END PUBLIC KEY-----"; + + $user_id = 979; + $data['agetId'] = "FWH000015822"; + $data['custId'] = "FWH000015822"; + $data['orderNo'] = "dlh".time().$user_id; + $data['txamt'] = 1; + $data['openid'] = $post['openid']; + $data['payWay'] = 1; + $data['ip'] = $_SERVER['REMOTE_ADDR']; + $data['timeStamp'] = date("Y-m-d H:i:s"); + $data['version'] = "1.0.0"; + sort($data); + $d =http_build_query($data); + $sha256 = hash('sha256', $d); + openssl_public_encrypt($d,$msg,$publicKey); + $msgd = base64_encode($msg); + } // public static function distributionPay($user_id,$post,$client){ $out_trade_no = createSn('user', 'id'); diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 40a58f02..712dcb70 100755 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -105,7 +105,18 @@ class PayNotifyLogic return $order_log_data; } - + private static function distribution($order_sn, $extra = []) + { + $orders = Db::name("distribution_pay")->where("order_sn",$order_sn)->find(); + if (isset($extra['transaction_id'])) { + $data['transaction_id'] = $extra['transaction_id']; + } + if($orders['transaction_id']!=null){ + $data['pay_time'] = date("Y-m-d H:i:s"); + $data['pay_status'] = 1; + Db::name("distribution_pay")->where("order_sn",$order_sn)->update($data); + } + } /** * @notes 父订单回调 * @param $order_sn diff --git a/app/common/server/WeChatPayServer.php b/app/common/server/WeChatPayServer.php index 8ba9b280..40875a29 100755 --- a/app/common/server/WeChatPayServer.php +++ b/app/common/server/WeChatPayServer.php @@ -219,7 +219,7 @@ class WeChatPayServer 'total_fee' => $post['money'] * 100, // 单位:分 'notify_url' => $notify_url, 'openid' => $auth['openid'] ?? '', - 'attach' => 'trade' + 'attach' => 'distribution' ]; $attributes['out_trade_no'] = $out_trade_no. $attributes['trade_type'] . $client; $result = $app->order->unify($attributes);