From 79434da3f150b68171f1cd702deaf657f7690031 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Mon, 29 Jun 2026 21:07:52 +0800 Subject: [PATCH] 1 --- app/Services/PayService.php | 73 ++++++++++++++++++------------------ app/Services/WxMpService.php | 3 +- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/app/Services/PayService.php b/app/Services/PayService.php index f11b54c2..e23a4174 100644 --- a/app/Services/PayService.php +++ b/app/Services/PayService.php @@ -6,6 +6,7 @@ use App\Enums\OfflineOrderStatus; use App\Enums\SocialiteType; use App\Exceptions\BizException; use App\Exceptions\InvalidPaySerialNumberException; +use App\Jobs\UploadShippingInfoJob; use App\Models\PayLog; use App\Models\{OfflineOrder, Order, OrderPre, SocialiteUser}; @@ -94,43 +95,41 @@ class PayService (new \App\Services\VipService())->success($payable, ['pay_at' => $payLog->pay_at]); } - // 延迟1分钟执行, 不然会出现错误信息: (10060001)支付单不存在 - sleep(60); - // 订单支付成功, 调用发货信息API - try { - if (!$userId) { - throw new BizException("未找到userId"); - } - $socialite = SocialiteUser::where('user_id', $userId)->where('socialite_type', SocialiteType::WechatMiniProgram)->first(); - if (!$socialite) { - throw new BizException("未找到 SocialiteUser 记录, userId: " . $userId); - } - $openid = $socialite->socialite_id; - if (!$openid) { - throw new BizException("未找到 openid, userId: " . $userId); - } - $data = [ - "order_key" => [ - // "mchid" => config("wechat.payment.sub.mch_id"), - // "out_trade_no" => $payLog->pay_sn, - "order_number_type" => 2, - "transaction_id" => $payLog->out_trade_no, - ], - "logistics_type" => 4, - "delivery_mode" => 1, - "shipping_list" => [ - ["item_desc" => "定制服务"] - ], - "upload_time" => $payLog->pay_at->format('Y-m-d\TH:i:s.vP'), - "payer" => [ - "openid" => $openid - ] - ]; - logger("微信小程序-发货信息录入", $data); - WxMpService::make()->uploadShippingInfo($data); - } catch (\Exception $e) { - logger()->error("微信小程序-发货信息录入, " . $e->getMessage(), ['pay_log_id' => $payLog->id]); - } + // TODO 延迟1分钟执行, 不然会出现错误信息: (10060001)支付单不存在 + // TODO 订单支付成功, 调用发货信息API + // try { + // if (!$userId) { + // throw new BizException("未找到userId"); + // } + // $socialite = SocialiteUser::where('user_id', $userId)->where('socialite_type', SocialiteType::WechatMiniProgram)->first(); + // if (!$socialite) { + // throw new BizException("未找到 SocialiteUser 记录, userId: " . $userId); + // } + // $openid = $socialite->socialite_id; + // if (!$openid) { + // throw new BizException("未找到 openid, userId: " . $userId); + // } + // $data = [ + // "order_key" => [ + // // "mchid" => config("wechat.payment.sub.mch_id"), + // // "out_trade_no" => $payLog->pay_sn, + // "order_number_type" => 2, + // "transaction_id" => $payLog->out_trade_no, + // ], + // "logistics_type" => 4, + // "delivery_mode" => 1, + // "shipping_list" => [ + // ["item_desc" => "定制服务"] + // ], + // "upload_time" => $payLog->pay_at->format('Y-m-d\TH:i:s.vP'), + // "payer" => [ + // "openid" => $openid + // ] + // ]; + // WxMpService::make()->uploadShippingInfo($data); + // } catch (\Exception $e) { + // logger()->error("微信小程序-发货信息录入, " . $e->getMessage(), ['pay_log_id' => $payLog->id]); + // } return $payLog; } diff --git a/app/Services/WxMpService.php b/app/Services/WxMpService.php index bd6c7b55..08d736c4 100644 --- a/app/Services/WxMpService.php +++ b/app/Services/WxMpService.php @@ -19,6 +19,7 @@ class WxMpService */ public function uploadShippingInfo(array $data) { + logger("微信小程序-发货信息录入, 参数", $data); $app = Factory::miniProgram(config('wechat.mini_program.default')); $accessToken = $app->access_token->getToken()['access_token']; $url = "https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token=" . $accessToken; @@ -26,7 +27,7 @@ class WxMpService $response->throw(); $result = $response->json(); - logger("微信小程序-发货信息录入", $result); + logger("微信小程序-发货信息录入, 结果", $result); $code = data_get($result, "errcode"); if ($code != 0) { throw new BizException("失败: (".$code.")" . data_get($result, "errmsg"));