fix(order): calculate invitation commission after balance deduction (#1020)
Calculate invitation commission from the amount remaining after balance deductions, preventing duplicate commission on internally credited payments.
This commit is contained in:
parent
60ba57142b
commit
c9ef5768e0
@ -74,12 +74,14 @@ class OrderService
|
|||||||
|
|
||||||
$orderService->setVipDiscount($user);
|
$orderService->setVipDiscount($user);
|
||||||
$orderService->setOrderType($user);
|
$orderService->setOrderType($user);
|
||||||
$orderService->setInvite(user: $user);
|
|
||||||
|
|
||||||
if ($user->balance && $order->total_amount > 0) {
|
if ($user->balance && $order->total_amount > 0) {
|
||||||
$orderService->handleUserBalance($user, $userService);
|
$orderService->handleUserBalance($user, $userService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 余额抵扣后的 total_amount 才是用户实际支付金额,返利必须基于该金额计算。
|
||||||
|
$orderService->setInvite(user: $user);
|
||||||
|
|
||||||
if (!$order->save()) {
|
if (!$order->save()) {
|
||||||
throw new ApiException(__('Failed to create order'));
|
throw new ApiException(__('Failed to create order'));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user