6
0
Fork 0

微信分账金额保留整数

base
panliang 2023-11-03 10:02:21 +08:00
parent 13058f86c1
commit f52746e965
3 changed files with 10 additions and 3 deletions

View File

@ -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);
}
}

View File

@ -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('/'));
}
/**

View File

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