zxiansheng 4 лет назад
Родитель
Сommit
8f7da82232

+ 51 - 4
common/helpers/bonus/BonusCalc.php

@@ -237,7 +237,7 @@ class BonusCalc extends BaseObject {
             $this->_updatePercent(68);
 
             // if($this->_sysConfig['openGL']['VALUE']) {
-            //     $this->calcBonusBdGL();
+                // $this->calcBonusBdGL();
             // }
             // $t13 = microtime(true);
             // echo('计算报单管理奖'.($this->_sysConfig['openGL']['VALUE']?'完成':'关闭').',耗时:' . round($t13 - $t11, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
@@ -261,17 +261,26 @@ class BonusCalc extends BaseObject {
             // if($this->_sysConfig['openVIP']['VALUE']) {
             //     $this->calcBonusVIP();
             // }
-            // $t17 = microtime(true);
+            $t17 = microtime(true);
             // echo('计算VIP奖'.($this->_sysConfig['openVIP']['VALUE']?'完成':'关闭').',耗时:' . round($t17 - $t16, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             // $this->_updatePercent(60);
 
             // if($this->_sysConfig['openJXS']['VALUE']) {
             //     $this->calcBonusStandard();
             // }
-             $t18 = microtime(true);
+             
             // echo('计算达标奖'.($this->_sysConfig['openJXS']['VALUE']?'完成':'关闭').',耗时:' . round($t18 - $t17, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             // $this->_updatePercent(65);
 
+            // 蓝星奖入库,实际上是插入有奖金会员数据缓存中.蓝星奖即是新的管理奖
+            //if($this->_sysConfig['openGL']['VALUE']) {
+                $this->calcBonusBsGL(); // ===============================todo===================
+            // }
+            $t18 = microtime(true);
+            echo('计算蓝星管理奖'.($this->_sysConfig['openGL']['VALUE']?'完成':'关闭').',耗时:' . round($t18 - $t17, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            $this->_updatePercent(65);
+
+
             // 1. 封期 2. 执行 存储过程,月奖要插入到AR_CALC_MONTH_BONUS_USER表中. 这里直接入库
             // 存储过程分2部分,一部分插入到月奖表中. 一部分计算真正奖金数据.分2部分进行执行.
             //把奖金会员写入缓存 - 把往期有月奖金的会员加到本期有奖会员缓存列表中
@@ -1572,6 +1581,37 @@ class BonusCalc extends BaseObject {
         return true;
     }
 
+    /**
+     * 蓝星奖金/即新的管理奖金
+     * @param int $offset
+     * @return bool
+     * @throws \yii\db\Exception
+     */
+    public function calcBonusBsGL(int $offset = 0) {
+        if( !$this->_isCalcMonth ) {
+            // 不是结算月,则不进行计算
+            return false;
+        }
+        // 从缓存获取分页有收入的会员信息
+        $allData = CalcBonusBS::findUseDbCalc()
+            ->where('PERIOD_NUM=:PERIOD_NUM', [':PERIOD_NUM' => $this->_periodNum])
+            ->groupBy('USER_ID')
+            ->offset($offset)
+            ->limit($this->_limit)
+            ->asArray()
+            ->all();
+        if ($allData) {
+            foreach ($allData as $user) {
+                // 添加到有奖励信息的数据中
+                CalcCache::addHasBonusUsers($user['USER_ID'], $this->_periodNum);
+                //CalcCache::addHasMonthBonusUsers($user['USER_ID'], $this->_periodNum);
+
+            }
+            return $this->calcBonusBsGL($offset + $this->_limit);
+        }
+        unset($allData);
+        return true;
+    }
 
     /**
      * 报单管理奖
@@ -2940,6 +2980,10 @@ class BonusCalc extends BaseObject {
     public function loopBonusUsers($offset = 0) {
         echo sprintf("时间:[%s]缓存奖金数据入库,当前offset为:【%s】" . PHP_EOL, date('Y-m-d H:i:s', time()) , $offset);
         // 从缓存列表里面从底层往上倒序获取会员
+
+        // 这里有问题,因为蓝星奖,是存储过程计算的,并没有加入缓存,这里需要修改.
+        // 给用户发送兑换积分,也需要进行调整查看。
+        // CalcCache::addHasBonusUsers($everyData['USER_ID'], $this->_periodNum);
         $allData = CalcCache::getHasBonusUsers($this->_periodNum, $offset, $this->_limit);
         if($allData){
             $insertDataBonus = [];
@@ -3005,6 +3049,7 @@ class BonusCalc extends BaseObject {
         $blueStartAmount = 0;
         $buleStartOriBonus = 0;
         $buleStartManageTax = 0;
+        $exchangePoints = 0; // 蓝星奖,即新的管理奖. 产生的兑换积分
         if( $this->_isCalcMonth ) {
             //查看是否复消300
             $monthPerfData = CalcCache::nowMonthPerf($userId, $this->_periodNum);
@@ -3023,7 +3068,7 @@ class BonusCalc extends BaseObject {
                         ':USER_ID' => $userId
                     ]
                 )
-                ->select('AMOUNT,ORI_BONUS,MANAGE_TAX')
+                ->select('AMOUNT,ORI_BONUS,MANAGE_TAX,LEVEL_ID,PRODUCT_POINT')
                 ->limit(1)
                 ->orderBy('CREATED_AT DESC')
                 ->asArray()
@@ -3037,6 +3082,7 @@ class BonusCalc extends BaseObject {
                 $realBonusGx += $bonusGxSum + $bonus['BONUS_GX'];
                 $realBonusBs = $blueStartAmount; // 蓝星奖直接取数据库中算好的值
                 $bonusReal += $realBonusGx + $realBonusBs;
+                $exchangePoints = isset($userBS['PRODUCT_POINT']) && !empty($userBS['PRODUCT_POINT']) ? $userBS['PRODUCT_POINT'] : 0; // 兑换积分
 
                 $bonus['BONUS_TOTAL'] = $bonus['BONUS_TOTAL'] + $buleStartOriBonus; // 管理奖在存储过程计算,这里单独加上管理奖(即蓝星奖)
                 unset($monthSumData, $bonusGxSum);
@@ -3102,6 +3148,7 @@ class BonusCalc extends BaseObject {
             'LAST_REC_REAL_NAME' => $baseInfo['REC_REAL_NAME'],
             'LAST_CON_USER_NAME' => $baseInfo['CON_USER_NAME'],
             'LAST_CON_REAL_NAME' => $baseInfo['CON_REAL_NAME'],
+            'EXCHANGE_POINTS' => $exchangePoints, // 兑换积分
 //            'LAST_LOCATION' => $baseInfo['LOCATION'] ? $baseInfo['LOCATION'] : 1,
             //@todo
             'LAST_LOCATION' => 1,

+ 1 - 1
common/helpers/bonus/BonusSend.php

@@ -152,7 +152,7 @@ class BonusSend extends BaseObject {
             $t7 = microtime(true);
             echo('更新会员累计业绩完成,耗时:' . round($t7 - $t6, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
 
-            $this->updateUserPerfMonth();
+            $this->updateUserPerfMonth(); // 月业绩,蓝星奖金(即新团队奖,需要特殊处理)
             $this->_updatePercent(90);
             $t8 = microtime(true);
             echo('更新会员累计月业绩完成,耗时:' . round($t8 - $t7, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);

+ 9 - 4
frontendApi/modules/v1/controllers/SiteController.php

@@ -198,22 +198,27 @@ class SiteController extends BaseController
         }
 
         if($menu['allow']=='transferRecordSwitch'){
-            $transferRecordSwitch = Cache::getSystemConfig()['transferRecordSwitch']['VALUE'];
+            $transferRecordSwitch = isset(Cache::getSystemConfig()['transferRecordSwitch']) ? Cache::getSystemConfig()['transferRecordSwitch']['VALUE'] : '';
             if($transferRecordSwitch) return false;
         }
 
         if($menu['allow']=='transferSwitch'){
-            $transferSwitch = Cache::getSystemConfig()['transferSwitch']['VALUE'];
+            $transferSwitch = isset(Cache::getSystemConfig()['transferSwitch']) ? Cache::getSystemConfig()['transferSwitch']['VALUE'] : '';
             if($transferSwitch) return false;
         }
 
         if($menu['allow']=='pastBonusSwitch'){
-            $pastBonusSwitch = Cache::getSystemConfig()['pastBonusSwitch']['VALUE'];
+            $pastBonusSwitch = isset(Cache::getSystemConfig()['pastBonusSwitch']) 
+                ? Cache::getSystemConfig()['pastBonusSwitch']['VALUE'] 
+                : '';
             if($pastBonusSwitch) return false;
         }
 
         if($menu['allow']=='newBonusSwitch'){
-            $newBonusSwitch = Cache::getSystemConfig()['newBonusSwitch']['VALUE'];
+            // ??? 
+            $newBonusSwitch = isset(Cache::getSystemConfig()['newBonusSwitch']) 
+                ? Cache::getSystemConfig()['newBonusSwitch']['VALUE'] 
+                : '';
             if($newBonusSwitch) return false;
         }