From c9ef5768e0fa0b819c647cf6aefd0850e436652d Mon Sep 17 00:00:00 2001 From: yootus <151767033+yootus@users.noreply.github.com> Date: Sun, 30 Aug 2026 00:33:14 +0800 Subject: [PATCH] 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. --- app/Services/OrderService.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Services/OrderService.php b/app/Services/OrderService.php index 1761315..6651eaa 100644 --- a/app/Services/OrderService.php +++ b/app/Services/OrderService.php @@ -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')); }