diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php index e1d5c81..dc35889 100644 --- a/app/api/controller/PayController.php +++ b/app/api/controller/PayController.php @@ -37,22 +37,26 @@ class PayController extends BaseApiController { $config = Config::get('payment'); Pay::config($config); - $message = Pay::wechat()->callback(); - if ($message['trade_state'] === 'SUCCESS') { - $extra['transaction_id'] = $message['transaction_id']; - $attach = $message['attach']; - $message['out_trade_no'] = mb_substr($message['out_trade_no'], 0, 18); - switch ($attach) { - case 'cashierclass': - $order = Cashierclass::where(['number' => $message['out_trade_no']])->findOrEmpty(); - if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) { - return true; - } - PayNotifyLogic::handle('cashierclass', $message['out_trade_no'], $extra); - break; + $result = Pay::wechat()->callback(Request()->post()); + if($result && $result->event_type=='TRANSACTION.SUCCESS'){ + $ciphertext=$result->resource->ciphertext; + if ($ciphertext['trade_state'] === 'SUCCESS') { + $extra['transaction_id'] = $ciphertext['transaction_id']; + $attach = $ciphertext['attach']; + $message['out_trade_no'] = mb_substr($ciphertext['out_trade_no'], 0, 18); + switch ($attach) { + case 'cashierclass': + $order = Cashierclass::where(['number' => $message['out_trade_no']])->findOrEmpty(); + if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) { + return true; + } + PayNotifyLogic::handle('cashierclass', $message['out_trade_no'], $ciphertext); + break; + } + return Pay::wechat()->success(); } - return Pay::wechat()->success(); } + // return (new WeChatPayService(UserTerminalEnum::WECHAT_MMP))->notify(); } } diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index d538f17..858c099 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -66,8 +66,8 @@ class PayNotifyLogic extends BaseLogic // 更新充值订单状态 // $order->transaction_id = $extra['transaction_id']; - $order->paid = PayEnum::ISPAID; - $order->save(); + // $order->paid = PayEnum::ISPAID; + // $order->save(); } diff --git a/composer.json b/composer.json index 33fc984..76de034 100644 --- a/composer.json +++ b/composer.json @@ -25,9 +25,9 @@ }, "require": { "php": ">=7.2", - "workerman/webman-framework": "^1.4.7", - "monolog/monolog": "^2.0", - "webman/think-orm": "^1.0", + "workerman/webman-framework": "v1.5.16", + "monolog/monolog": "^2.2", + "webman/think-orm": "v1.1.1", "vlucas/phpdotenv": "^5.4", "psr/container": "^1.1.1", "ext-json": "*", diff --git a/composer.lock b/composer.lock index 6d0c7c3..c4ef3c9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "10536b047d5ed5c08b1aa7a603970cb7", + "content-hash": "738295d764b0a7e25449d6502fca73ac", "packages": [ { "name": "aliyuncs/oss-sdk-php",