Ver Fonte

会员升级

Kirin há 11 meses atrás
pai
commit
5c99477682
1 ficheiros alterados com 67 adições e 36 exclusões
  1. 67 36
      app/jobs/integral/IntegralJob.php

+ 67 - 36
app/jobs/integral/IntegralJob.php

@@ -146,27 +146,57 @@ class IntegralJob extends BaseJobs
                 $res = $res && $awardIntegralService->addLake(-$real_out, $info['id'], $mark);
 
                 $to_brokerage = bcdiv(bcmul($real_out, sys_config('extract_brokerage_ratio', 0)), 100, 2);
-                $balance = bcadd($user['brokerage_price'], $to_brokerage, 2);
-                $res = $res && $brokerageService->income('extract_integral', $info['uid'], [
-                        'type' => $info['type'] ? '贡献分' : '消费分',
-                        'price' => round($price, 2),
-                        'integral_num' => $info['num'],
-                        'number' => floatval($to_brokerage),
-                        'frozen_time' => 0
-                    ], $balance, $info['id']);
-                // 添加用户佣金
-                $res = $res && $userService->bcInc($info['uid'], 'brokerage_price', $to_brokerage, 'uid');
-
                 $to_energy = bcsub($real_out, $to_brokerage, 2);
-                $balance = bcadd($user['energy'], $to_energy, 2);
-                $res = $res && $billService->income('extract_integral', $info['uid'], [
-                        'type' => $info['type'] ? '贡献分' : '消费分',
-                        'price' => round($price, 2),
-                        'integral_num' => $info['num'],
-                        'number' => floatval($to_energy),
-                    ], $balance, $info['id']);
-                // 添加用户佣金
-                $res = $res && $userService->bcInc($info['uid'], 'energy', $to_energy, 'uid');
+                if ($to_energy > 0) {
+                    $balance = bcadd($user['energy'], $to_energy, 2);
+                    $res = $res && $billService->income('extract_integral', $info['uid'], [
+                            'type' => $info['type'] ? '贡献分' : '消费分',
+                            'price' => round($price, 2),
+                            'integral_num' => $info['num'],
+                            'number' => floatval($to_energy),
+                        ], $balance, $info['id']);
+                    // 添加用户佣金
+                    $res = $res && $userService->bcInc($info['uid'], 'energy', $to_energy, 'uid');
+                }
+
+                $to_now_money = 0;
+                $starts_return_time = sys_config('starts_return_time', 0);
+                if ($starts_return_time > 0) {
+                    $count = $awardIntegralService->search(['uid' => $user['uid'], 'type' => 0, 'status' => 1])->count();
+                    if ($count < $starts_return_time) {
+                        $to_now_money = $info['order_price'];
+                        if ($to_now_money > $to_brokerage) {
+                            $to_now_money = $to_brokerage;
+                        }
+                        $to_brokerage = bcsub($to_brokerage, $to_now_money, 2);
+                    }
+                }
+
+                if ($to_now_money > 0) {
+                    $balance = bcadd($user['now_money'], $to_now_money, 2);
+                    $res = $res && $moneyService->income('extract_integral', $info['uid'], [
+                            'type' => $info['type'] ? '贡献分' : '消费分',
+                            'price' => round($price, 2),
+                            'integral_num' => $info['num'],
+                            'number' => floatval($to_now_money),
+                            'frozen_time' => 0
+                        ], $balance, $info['id']);
+                    // 添加用户佣金
+                    $res = $res && $userService->bcInc($info['uid'], 'now_money', $to_now_money, 'uid');
+                }
+
+                if ($to_brokerage > 0) {
+                    $balance = bcadd($user['brokerage_price'], $to_brokerage, 2);
+                    $res = $res && $brokerageService->income('extract_integral', $info['uid'], [
+                            'type' => $info['type'] ? '贡献分' : '消费分',
+                            'price' => round($price, 2),
+                            'integral_num' => $info['num'],
+                            'number' => floatval($to_brokerage),
+                            'frozen_time' => 0
+                        ], $balance, $info['id']);
+                    // 添加用户佣金
+                    $res = $res && $userService->bcInc($info['uid'], 'brokerage_price', $to_brokerage, 'uid');
+                }
 
                 $res = $res && $awardIntegralService->update($info['id'], ['handle' => 0, 'extract_sum_real' => $sum, 'status' => 1, 'extract_time' => time()]);
             }
@@ -218,16 +248,30 @@ class IntegralJob extends BaseJobs
                 $mark = '用户积分出局,出局时价格' . $price;
                 $res = $res && $awardIntegralService->addLake(-$real_out, $info['id'], $mark);
 
+                $to_brokerage = bcdiv(bcmul($real_out, sys_config('extract_brokerage_ratio', 0)), 100, 2);
+                $to_energy = bcsub($real_out, $to_brokerage, 2);
+                if ($to_energy > 0) {
+                    $balance = bcadd($user['energy'], $to_energy, 2);
+                    $res = $res && $billService->income('extract_integral', $info['uid'], [
+                            'type' => $info['type'] ? '贡献分' : '消费分',
+                            'price' => round($price, 2),
+                            'integral_num' => $info['num'],
+                            'number' => floatval($to_energy),
+                        ], $balance, $info['id']);
+                    // 添加用户佣金
+                    $res = $res && $userService->bcInc($info['uid'], 'energy', $to_energy, 'uid');
+                }
+
                 $to_now_money = 0;
                 $starts_return_time = sys_config('starts_return_time', 0);
                 if ($starts_return_time > 0) {
                     $count = $awardIntegralService->search(['uid' => $user['uid'], 'type' => 0, 'status' => 1])->count();
                     if ($count < $starts_return_time) {
                         $to_now_money = $info['order_price'];
-                        if ($to_now_money > $real_out) {
-                            $to_now_money = $real_out;
+                        if ($to_now_money > $to_brokerage) {
+                            $to_now_money = $to_brokerage;
                         }
-                        $real_out = bcsub($real_out, $to_now_money, 2);
+                        $to_brokerage = bcsub($to_brokerage, $to_now_money, 2);
                     }
                 }
 
@@ -244,7 +288,6 @@ class IntegralJob extends BaseJobs
                     $res = $res && $userService->bcInc($info['uid'], 'now_money', $to_now_money, 'uid');
                 }
 
-                $to_brokerage = bcdiv(bcmul($real_out, sys_config('extract_brokerage_ratio', 0)), 100, 2);
                 if ($to_brokerage > 0) {
                     $balance = bcadd($user['brokerage_price'], $to_brokerage, 2);
                     $res = $res && $brokerageService->income('extract_integral', $info['uid'], [
@@ -258,18 +301,6 @@ class IntegralJob extends BaseJobs
                     $res = $res && $userService->bcInc($info['uid'], 'brokerage_price', $to_brokerage, 'uid');
                 }
 
-                $to_energy = bcsub($real_out, $to_brokerage, 2);
-                if ($to_energy > 0) {
-                    $balance = bcadd($user['energy'], $to_energy, 2);
-                    $res = $res && $billService->income('extract_integral', $info['uid'], [
-                            'type' => $info['type'] ? '贡献分' : '消费分',
-                            'price' => round($price, 2),
-                            'integral_num' => $info['num'],
-                            'number' => floatval($to_energy),
-                        ], $balance, $info['id']);
-                    // 添加用户佣金
-                    $res = $res && $userService->bcInc($info['uid'], 'energy', $to_energy, 'uid');
-                }
                 $res = $res && $awardIntegralService->update($info['id'], ['handle' => 0, 'extract_sum_real' => $sum, 'status' => 1, 'extract_time' => time()]);
             }
             if ($to_top > 0) {