diff --git a/app/Http/Controllers/OrderController.php b/app/Http/Controllers/OrderController.php index 3e92ca72..149d158d 100755 --- a/app/Http/Controllers/OrderController.php +++ b/app/Http/Controllers/OrderController.php @@ -125,16 +125,6 @@ class OrderController extends Controller } else { $order->type = 1; } - // invite process - if ($user->invite_user_id) { - $order->invite_user_id = $user->invite_user_id; - $inviter = User::find($user->invite_user_id); - if ($inviter && $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); - } - } // coupon process if (isset($coupon)) { switch ($coupon->type) { @@ -159,7 +149,16 @@ class OrderController extends Controller $order->total_amount = 0; $order->status = 1; } - + // invite process + if ($user->invite_user_id && $order->total_amount > 0) { + $order->invite_user_id = $user->invite_user_id; + $inviter = User::find($user->invite_user_id); + if ($inviter && $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()) { DB::rollback(); abort(500, '订单创建失败');