From 1b6e73bd0bfc701082d25e04b761e4285ce3944b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Wed, 29 Dec 2021 10:20:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Http/Controllers/WeChatPayController.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/Endpoint/Callback/Http/Controllers/WeChatPayController.php b/app/Endpoint/Callback/Http/Controllers/WeChatPayController.php index 771b531e..17240214 100644 --- a/app/Endpoint/Callback/Http/Controllers/WeChatPayController.php +++ b/app/Endpoint/Callback/Http/Controllers/WeChatPayController.php @@ -11,6 +11,7 @@ use App\Services\WeChatPayService; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; use Throwable; class WeChatPayController extends Controller @@ -24,6 +25,8 @@ class WeChatPayController extends Controller public function paidNotify(WeChatPayService $weChatPayService) { return $weChatPayService->handlePaidNotify(function ($message, $fail) { + $this->log('paid notify', $message); + // 通信失败 if (data_get($message, 'return_code') !== 'SUCCESS') { return $fail('通信失败'); @@ -67,6 +70,8 @@ class WeChatPayController extends Controller public function orderRefundedNotify(WeChatPayService $weChatPayService) { return $weChatPayService->handleRefundedNotify(function ($message, $reqInfo, $fail) { + $this->log('refund notify', $reqInfo); + // 通信失败 if (data_get($message, 'return_code') !== 'SUCCESS') { return $fail('通信失败'); @@ -85,4 +90,19 @@ class WeChatPayController extends Controller return true; }); } + + /** + * 微信回调日志 + * + * @param string $message + * @param array $context + * @return void + */ + protected function log(string $message, array $context = []) + { + return Log::build([ + 'driver' => 'daily', + 'path' => storage_path('logs/wxpay-notify.log'), + ])->info($message, $context); + } }