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" => "推荐返利" ]); }