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:
yootus 2026-08-30 00:33:14 +08:00 committed by xboard
parent 60ba57142b
commit c9ef5768e0

View File

@ -74,12 +74,14 @@ class OrderService
$orderService->setVipDiscount($user);
$orderService->setOrderType($user);
$orderService->setInvite(user: $user);
if ($user->balance && $order->total_amount > 0) {
$orderService->handleUserBalance($user, $userService);
}
// 余额抵扣后的 total_amount 才是用户实际支付金额,返利必须基于该金额计算。
$orderService->setInvite(user: $user);
if (!$order->save()) {
throw new ApiException(__('Failed to create order'));
}