From f52746e965ce55c4bacfc2e782e3333250e7ed24 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Fri, 3 Nov 2023 10:02:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=88=86=E8=B4=A6=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E4=BF=9D=E7=95=99=E6=95=B4=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/OrderProfitCheck.php | 9 ++++++++- app/Exceptions/Handler.php | 2 +- app/Services/DistributeService.php | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/OrderProfitCheck.php b/app/Console/Commands/OrderProfitCheck.php index 3f290762..2d374535 100644 --- a/app/Console/Commands/OrderProfitCheck.php +++ b/app/Console/Commands/OrderProfitCheck.php @@ -45,12 +45,19 @@ class OrderProfitCheck extends Command $service1 = new DistributeService(); $list = OrderProfit::where('status', 1)->get()->groupBy('order_id'); foreach ($list as $order_id => $profits) { - $transaction_id = Order::where('id', $order_id)->value('out_trade_no'); + $order = Order::findOrFail($order_id); + $transaction_id = $order->out_trade_no; $sn = data_get($profits->first(), 'pay_no'); if ($transaction_id) { $result = $service->queryShare($transaction_id, $sn); $status = data_get($result, 'status'); if ($status == 'FINISHED') { + // 修改订单分账状态 + $attributes = ['share_sn' => $sn, 'status' => 'N']; + $order->update([ + 'wx_share' => $order->wx_share ? array_merge($order->wx_share, $attributes) : $attributes, + 'profit_paid' => now(), + ]); $service1->success($profits, $result); } } diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index ddc726d7..5b241d6b 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -102,7 +102,7 @@ class Handler extends ExceptionHandler 'errcode' => 401, 'message' => $exception->getMessage(), ], 401) - : redirect()->guest($exception->redirectTo() ?? route('login')); + : redirect()->guest($exception->redirectTo() ?? url('/')); } /** diff --git a/app/Services/DistributeService.php b/app/Services/DistributeService.php index 6962e5a3..f7360900 100644 --- a/app/Services/DistributeService.php +++ b/app/Services/DistributeService.php @@ -238,7 +238,7 @@ class DistributeService array_push($receivers, [ "type" => "PERSONAL_SUB_OPENID", "account" => $openid, - "amount" => $item->money * 100, + "amount" => floor($item->money * 100), "description" => "推荐返利" ]); }