Selaa lähdekoodia

update: commission stat

tokumeikoi 2 vuotta sitten
vanhempi
säilyke
37f1f64442

+ 1 - 2
app/Console/Commands/CheckCommission.php

@@ -80,15 +80,14 @@ class CheckCommission extends Command
 
     public function payHandle($inviteUserId, Order $order)
     {
+        $level = 3;
         if ((int)config('v2board.commission_distribution_enable', 0)) {
-            $level = 3;
             $commissionShareLevels = [
                 0 => (int)config('v2board.commission_distribution_l1'),
                 1 => (int)config('v2board.commission_distribution_l2'),
                 2 => (int)config('v2board.commission_distribution_l3')
             ];
         } else {
-            $level = 3;
             $commissionShareLevels = [
                 0 => 100
             ];

+ 10 - 8
app/Http/Controllers/User/InviteController.php

@@ -58,19 +58,21 @@ class InviteController extends Controller
         if ($user->commission_rate) {
             $commission_rate = $user->commission_rate;
         }
+        $uncheck_commission_balance = (int)Order::where('status', 3)
+            ->where('commission_status', 0)
+            ->where('invite_user_id', $request->user['id'])
+            ->sum('commission_balance');
+        if (config('v2board.commission_distribution_enable', 0)) {
+            $uncheck_commission_balance = $uncheck_commission_balance * (config('v2board.commission_distribution_l1') / 100);
+        }
         $stat = [
             //已注册用户数
             (int)User::where('invite_user_id', $request->user['id'])->count(),
             //有效的佣金
-            (int)Order::where('status', 3)
-                ->where('commission_status', 2)
-                ->where('invite_user_id', $request->user['id'])
-                ->sum('commission_balance'),
+            (int)CommissionLog::where('invite_user_id', $request->user['id'])
+                ->sum('get_amount'),
             //确认中的佣金
-            (int)Order::where('status', 3)
-                ->where('commission_status', 0)
-                ->where('invite_user_id', $request->user['id'])
-                ->sum('commission_balance'),
+            $uncheck_commission_balance,
             //佣金比例
             (int)$commission_rate,
             //可用佣金