root 5 anos atrás
pai
commit
54a4eb2310
1 arquivos alterados com 8 adições e 1 exclusões
  1. 8 1
      app/Http/Controllers/OrderController.php

+ 8 - 1
app/Http/Controllers/OrderController.php

@@ -86,7 +86,14 @@ class OrderController extends Controller
         }
         if ($user->invite_user_id) {
             $order->invite_user_id = $user->invite_user_id;
-            $order->commission_balance = $order->total_amount * (config('v2board.invite_commission', 10) / 100);
+            $inviter = User::find($user->invite_user_id);
+            if ($inviter) {
+                if ($inviter->commission_rate) {
+                    $order->commission_balance = $order->total_amount * ($inviter->commission_rate / 100);
+                } else {
+                    $order->commission_balance = $order->total_amount * (config('v2board.invite_commission', 10) / 100);
+                }
+            }
         }
         if (!$order->save()) {
             abort(500, '订单创建失败');