root 3 anni fa
parent
commit
acc1543310

+ 48 - 0
common/helpers/bonus/CalcCache.php

@@ -120,6 +120,54 @@ class CalcCache {
         \Yii::$app->redis->del(Cache::USER_RELATION_PARENTS);
     }
 
+    /**
+     * 清空所有临时计算用到的缓存
+     * @param $periodNum
+     */
+    public static function clearAll($periodNum) {
+        //Yii::$app->redis->del(Yii::$app->redis->keys('calc*'));
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_USER_ACTIVE . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_USER_INFO . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_USER_BONUS . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_PERIOD_MONTH_CALC_BONUS . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_SURPLUS_PERF . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_USER_PERF . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_NOW_PERIOD_PERF . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_LAST_MONTH_PERF . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_NOW_MONTH_PERF . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_NOW_MONTH_LAST_PERIOD_RECONSUME_POINTS . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_EMP_NUM_PERF . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_BONUS . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_FW_BONUS . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_PERF_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_PERF_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_MONTH_PERF_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_MONTH_PERF_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_STANDARD_MONTH_PERF_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_STANDARD_MONTH_PERF_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_BD_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_BD_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_INCOME_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_INCOME_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_BONUS_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_BONUS_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_FW_BONUS_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_FW_BONUS_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_MONTH_BONUS_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_MONTH_BONUS_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_LS_PCS_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_LS_PCS_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_CF_PERCENT_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_CF_PERCENT_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_LX_PERCENT_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_LX_PERCENT_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_DEC_ROLE_CONFIG . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_USER_INFO_CHILD_ONE_DEEP . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_FW_BONUS_LIST_DATA . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_BONUS_CROWN_CROWN_LIST_DATA . $periodNum);
+    }
+
     /**
      * 会员信息加入缓存
      * @param $periodNum

+ 0 - 14
common/helpers/bonus/CalcServeBonusCalc.php

@@ -17,32 +17,18 @@ use common\models\CalcBonusBD;
 use common\models\CalcBonusBS;
 use common\models\CalcBonusQuarter;
 use common\models\CalcBonusGarage;
-use common\models\CalcBonusGL;
-use common\models\CalcBonusGX;
 use common\models\CalcBonusQY;
-use common\models\CalcBonusStandard;
 use common\models\CalcBonusTG;
 use common\models\CalcBonusTourism;
 use common\models\CalcBonusVilla;
-use common\models\CalcBonusVIP;
-use common\models\CalcBonusXF;
-use common\models\CalcBonusYC;
-use common\models\CalcBonusYJ;
 use common\models\CalcMonthBonusUser;
-use common\models\Config;
-use common\models\PerfCompany;
 use common\models\PerfMonth;
 use common\models\PerfPeriod;
 use common\models\Period;
-use common\models\DeclarationLevel;
-use common\models\EmployLevel;
 use common\models\FlowBonus;
-use common\models\ScoreMonth;
 use common\models\StarCrownLevel;
 use yii\base\BaseObject;
-use yii\base\Exception;
 use yii\base\StaticInstanceTrait;
-use yii\helpers\Json;
 use yii\db\Query;
 
 class CalcServeBonusCalc extends BaseObject {

+ 13 - 28
common/helpers/bonus/CalcServePerfCalc.php

@@ -36,14 +36,8 @@ class CalcServePerfCalc {
     private $_lastCalcMonth;
     private $_lastCalcYearMonth;
     private $_lastPeriodNum;
-    private $_lastPeriodYear;
-    private $_lastPeriodMonth;
-    private $_lastPeriodYearMonth;
-    private $_lastTime = 0;
     private $_periodObj;
     private $_periodDataArr;
-    //pv
-    private $_pvRatio;
 
     const LOOP_FINISH = 1;
     const LOOP_CONTINUE = 2;
@@ -90,6 +84,12 @@ class CalcServePerfCalc {
                 echo('触发时间:【'.date('Y-m-d H:i:s', time()).'】'.'业绩期表中,此期状态不正确');
                 
                 return false;
+            } else {
+                // 记录初始化数据,用户总数,业绩单业绩总pv值.
+                // @todo
+
+                // 将IS_PREPARE改成2,计算中
+                Period::updateCalcProcess(2, $this->_periodNum);
             }
             $t1 = microtime(true);
             //二、初始化
@@ -109,30 +109,30 @@ class CalcServePerfCalc {
             //七、 添加缓存中用户数据
             CalcCache::addUsers($this->_periodNum);
             $t3 = microtime(true);
-            echo('计算业绩向缓存中加入用户完成,耗时:' . round($t3 - $t2, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            echo(date('Y-m-d H:i:s',time()).'计算业绩向缓存中加入用户完成,耗时:' . round($t3 - $t2, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(20);
             // 八、循环累计用户各项业绩数据
             $this->loopGrandPerf();
             $t4 = microtime(true);
-            echo('累计用户业绩完成' . round($t4 - $t3, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            echo(date('Y-m-d H:i:s',time()).'累计用户业绩完成' . round($t4 - $t3, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             // 九、本期业绩入库
             $this->loopWriteNowPerf();
             $t6 = microtime(true);
-            echo('本期业绩入库完成,耗时:' . round($t6 - $t4, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            echo(date('Y-m-d H:i:s',time()).'本期业绩入库完成,耗时:' . round($t6 - $t4, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(70);
             //十、计算月业绩表中的数据
             $this->loopCalcMonthPerfTableData();
             $t7 = microtime(true);
-            echo('计算月业绩表中的数据完成,耗时:' . round($t7 - $t6, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            echo(date('Y-m-d H:i:s',time()).'计算月业绩表中的数据完成,耗时:' . round($t7 - $t6, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(80);
             //十一、本月业绩入库
             $this->loopWriteMonthPerf();
             $t8 = microtime(true);
-            echo('本月业绩入库完成,耗时:' . round($t8 - $t7, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            echo(date('Y-m-d H:i:s',time()).'本月业绩入库完成,耗时:' . round($t8 - $t7, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(100);
             $t9 = microtime(true);
             
-            echo('计算业绩业绩结算全部完成,共耗时:' . round($t9 - $t8, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            echo(date('Y-m-d H:i:s',time()).'计算业绩业绩结算全部完成,共耗时:' . round($t9 - $t1, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
         } catch (\Exception $e) {
             $this->errorCalcTask();
             file_put_contents('error_test.txt', var_export([
@@ -172,8 +172,7 @@ class CalcServePerfCalc {
      */
     public function setCalcStatus($type, $periodNum = null) {
         if ($type == 'start') {
-            $this->_lastTime = !empty($periodNum) ? Date::nowTime() : $this->_lastTime;
-            Period::updateAll(['IS_PERFING' => 1, 'IS_PERFED' => Period::PERF_NONE, 'PERF_STARTED_AT' => $this->_lastTime], 'PERIOD_NUM=:PERIOD_NUM', [':PERIOD_NUM' => $this->_periodNum]);
+            Period::updateAll(['IS_PERFING' => 1, 'IS_PERFED' => Period::PERF_NONE, 'PERF_STARTED_AT' => Date::nowTime()], 'PERIOD_NUM=:PERIOD_NUM', [':PERIOD_NUM' => $this->_periodNum]);
         } elseif ($type == 'end') {
             Period::updateAll(['IS_PERFING' => 0, 'IS_PERFED' => Period::PERF_FINISH, 'PERFED_AT' => Date::nowTime()], 'PERIOD_NUM=:PERIOD_NUM', [':PERIOD_NUM' => $this->_periodNum]);
         } elseif ($type == 'fail') {
@@ -197,20 +196,7 @@ class CalcServePerfCalc {
         $this->_calcYear = $periodObj->getYear($this->_periodNum);
         $this->_calcMonth = $periodObj->getMonth($this->_periodNum);
         $this->_calcYearMonth = $periodObj->getYearMonth($this->_periodNum);
-        $lastYearMonthArr = $periodObj->getLastMonth($this->_periodNum);
-        $this->_lastCalcYear = $lastYearMonthArr['year'];
-        $this->_lastCalcMonth = $lastYearMonthArr['month'];
-        $this->_lastCalcYearMonth = $lastYearMonthArr['yearMonth'];
         $this->_lastPeriodNum = $this->_periodNum - 1;
-        if (Period::isExistsPeriodNum($this->_lastPeriodNum)) {
-            $this->_lastPeriodYear = $periodObj->getYear($this->_lastPeriodNum);
-            $this->_lastPeriodMonth = $periodObj->getMonth($this->_lastPeriodNum);
-            $this->_lastPeriodYearMonth = $periodObj->getYearMonth($this->_lastPeriodNum);
-        } else {
-            $this->_lastPeriodYear = 0;
-            $this->_lastPeriodMonth = 0;
-            $this->_lastPeriodYearMonth = 0;
-        }
     }
 
     /**
@@ -218,7 +204,6 @@ class CalcServePerfCalc {
      */
     public function clearTableData() {
         PerfPeriod::pageDeleteAll('PERIOD_NUM='.$this->_periodNum);// 周业绩
-        PerfOrder::pageDeleteAll('PERIOD_NUM='.$this->_periodNum);// 业绩单
         if ($this->_isCalcMonth) {
             PerfMonth::pageDeleteAll("CALC_MONTH='{$this->_calcYearMonth}'");// 月业绩表
         }

+ 15 - 279
common/models/Period.php

@@ -80,7 +80,7 @@ class Period extends \common\components\ActiveRecord
     {
         return [
             [['PERIOD_NUM', 'CALC_MONTH', 'CALC_YEAR', 'START_TIME', 'END_TIME', 'CREATED_AT'], 'required'],
-            [['PERIOD_NUM', 'CALC_MONTH', 'CALC_YEAR', 'START_TIME', 'END_TIME', 'IS_MONTH', 'IS_YEAR', 'IS_CLOSED', 'IS_PERFED', 'IS_CALCULATED', 'IS_SENT', 'IS_PERFING', 'IS_CALCING', 'IS_SENDING', 'CALC_PERCENT', 'SENT_PERCENT', 'CLOSED_AT', 'PERF_STARTED_AT', 'PERFED_AT', 'CALCULATE_STARTED_AT', 'CALCULATED_AT', 'SEND_STARTED_AT', 'SENT_AT', 'CREATED_AT'], 'integer'],
+            [['PERIOD_NUM', 'CALC_MONTH', 'CALC_YEAR', 'START_TIME', 'END_TIME', 'IS_MONTH', 'IS_YEAR', 'IS_PERFED', 'IS_CALCULATED', 'IS_SENT', 'IS_PERFING', 'IS_CALCING', 'IS_SENDING', 'CALC_PERCENT', 'SENT_PERCENT', 'CLOSED_AT', 'PERF_STARTED_AT', 'PERFED_AT', 'CALCULATE_STARTED_AT', 'CALCULATED_AT','CREATED_AT'], 'integer'],
             [['ID', 'PERF_ADMIN_ID', 'CLOSE_ADMIN_ID', 'CALC_ADMIN_ID', 'SENT_ADMIN_ID'], 'string', 'max' => 32],
             [['PERIOD_NUM'], 'unique'],
             [['ID'], 'unique'],
@@ -133,7 +133,6 @@ class Period extends \common\components\ActiveRecord
     public function setPeriodNum($periodNum = null){
         if (empty($periodNum)) {
             $this->nowPeriodArr = static::find()
-                ->where('IS_CLOSED=0')
                 ->where('IS_PREPARE=1')
                 ->orderBy('PERIOD_NUM ASC')
                 ->asArray()
@@ -145,7 +144,10 @@ class Period extends \common\components\ActiveRecord
             $this->periodArr = $this->nowPeriodArr;
             $periodNum = $this->nowPeriodArr['PERIOD_NUM'];
         } else {
-            $this->periodArr = static::findOneAsArray('PERIOD_NUM=:PERIOD_NUM AND IS_CLOSED=0 AND IS_PREPARE=1', [':PERIOD_NUM'=>$periodNum]);
+            $this->periodArr = static::findOneAsArray(
+                'PERIOD_NUM=:PERIOD_NUM AND IS_PREPARE=1', 
+                [':PERIOD_NUM'=>$periodNum]
+            );
             if (empty($this->periodArr)) {
 
                 return false;
@@ -580,289 +582,23 @@ class Period extends \common\components\ActiveRecord
         return false;
     }
 
-    /**
-     * 获取上月的年月
-     * @param $periodNum
-     * @return array
-     */
-    public function getLastMonth($periodNum = null){
-        $period = $this->setPeriodNum($periodNum);
-        if($period){
-            $year = $period['CALC_YEAR'];
-            $month = $period['CALC_MONTH'];
-            $lastYear = Date::lastMonth($year.'-'.$month, 'Y');
-            $lastMonth = Date::lastMonth($year.'-'.$month, 'm');
-            return [
-                'year' => $lastYear,
-                'month' => intval($lastMonth),
-                'yearMonth' => $lastYear.Tool::numFix($lastMonth, 2),
-            ];
-        } else {
-            return [
-                'year' => 0,
-                'month' => 0,
-                'yearMonth' => 0,
-            ];
-        }
-    }
-
-    /**
-     * 上几个月的年月
-     * @param int $num
-     * @param null $periodNum
-     * @return array
-     */
-    public function getLastNumMonth($num=1,$periodNum = null){
-        $period = $this->setPeriodNum($periodNum);
-        if($period){
-            $year = $period['CALC_YEAR'];
-            $month = $period['CALC_MONTH'];
-            $lastYear = Date::lastNumMonth($num,$year.'-'.$month, 'Y');
-            $lastMonth = Date::lastNumMonth($num,$year.'-'.$month, 'm');
-            return [
-                'year' => $lastYear,
-                'month' => intval($lastMonth),
-                'yearMonth' => $lastYear.Tool::numFix($lastMonth, 2),
-            ];
-        } else {
-            return [
-                'year' => 0,
-                'month' => 0,
-                'yearMonth' => 0,
-            ];
-        }
-    }
-
-    /**
-     * 下月的年月
-     * @param null $periodNum
-     * @return array
-     */
-    public function getNextMonth($periodNum = null){
-        $period = $this->setPeriodNum($periodNum);
-        if($period){
-            $year = $period['CALC_YEAR'];
-            $month = $period['CALC_MONTH'];
-            $nextYear = Date::nextMonth($year.'-'.$month, 'Y');
-            $nextMonth = Date::nextMonth($year.'-'.$month, 'm');
-            return [
-                'year' => $nextYear,
-                'month' => intval($nextMonth),
-                'yearMonth' => $nextYear.Tool::numFix($nextMonth, 2),
-            ];
-        } else {
-            return [
-                'year' => 0,
-                'month' => 0,
-                'yearMonth' => 0,
-            ];
-        }
-    }
-
-    /**
-     * 通过时间戳获取期
-     * @param $time
-     * @return array|null|\yii\db\ActiveRecord
-     */
-    public static function getPeriodFromTime($time){
-        return static::find()->where('START_TIME<=:TIME AND END_TIME>:TIME', [':TIME'=>$time])->asArray()->one();
-    }
-
-    /**
-     * 通过时间戳范围获取期间内的期
-     * @param $minTime
-     * @param $maxTime
-     * @return array|\yii\db\ActiveRecord[]
-     */
-    public static function getPeriodFromTimeRange($minTime, $maxTime){
-        return static::find()->where('END_TIME>:MIN_TIME AND START_TIME<:MAX_TIME', [':MIN_TIME'=>$minTime, ':MAX_TIME'=>$maxTime])->orderBy('PERIOD_NUM ASC')->asArray()->all();
-    }
-
-    /**
-     * 获取近几期的期数
-     * @param $num
-     * @return array
-     */
-    public static function getNearlyPeriodNum($num){
-        // 获取当前期
-        $period = self::instance();
-        $periodNum = $period->getNowPeriodNum();
-        // 获取前$num期的期数
-        $periodNums = [
-            $periodNum
-        ];
-        for($i=0;$i<$num;$i++){
-            if($periodNum - $i > 0){
-                // 查看该期是否存在
-                if(self::isExistsPeriodNum($periodNum - $i)){
-                    $periodNums[] = $periodNum - $i;
-                }
-            }
-        }
-        return array_reverse($periodNums);
-    }
-
-    /**
-     * 获取近几期的挂网期数
-     * @param $num
-     * @return array
-     */
-    public static function getNearlySendPeriodNum($num){
-        // 获取当前期
-        $period = self::instance();
-        $periodNum = $period->sentMaxPeriodNum();
-        // 获取前$num期的期数
-        $periodNums = [
-            $periodNum
-        ];
-        for($i=0;$i<$num;$i++){
-            if($periodNum - $i > 0){
-                // 查看该期是否存在
-                if(self::isExistsPeriodNum($periodNum - $i)){
-                    $periodNums[] = $periodNum - $i;
-                }
-            }
-        }
-        return array_reverse($periodNums);
-    }
-
-    /**
-     * 获取近几期的年月
-     * @param $num
-     * @return array
-     * @throws Exception
-     */
-    public static function getNearlyPeriodYearMonth($num){
-        // 获取当前期
-        $period = self::instance();
-        $periodNum = $period->getNowPeriodNum();
-        $nowYearMonth = $period->getNowYearMonth();
-        // 获取前$num期的期数
-        $periodYearMonths = [];
-        for($i=1;$i<=$num;$i++){
-            if($periodNum - $i > 0){
-                // 查看该期是否存在
-                if(self::isExistsPeriodNum($periodNum - $i)){
-                    $yearMonth = $period->getYearMonth($periodNum - $i);
-                    $periodYearMonths[] = [
-                        'yearMonth' => $yearMonth,
-                        'periodNum' => $periodNum - $i,
-                    ];
-                }
-            }
-        }
-        return array_reverse($periodYearMonths);
-    }
-
-    /**
-     * 获取本月所有已经挂网的期数
-     * @param $yearMonth
-     * @return array
-     */
-    public static function monthSentAllPeriodNum($yearMonth){
-        $year = intval(substr($yearMonth, 0, 4));
-        $month = intval(substr($yearMonth, 4, 2));
-        $allPeriod = Period::find()->where('CALC_YEAR=:CALC_YEAR AND CALC_MONTH=:CALC_MONTH AND IS_SENT=1', [':CALC_YEAR'=>$year, ':CALC_MONTH'=>$month])->select('PERIOD_NUM')->asArray()->all();
-        $result = [];
-        if($allPeriod){
-            foreach($allPeriod as $period){
-                $result[] = $period['PERIOD_NUM'];
-            }
-        }
-        return $result;
-    }
+    // 奖金计算,更新业绩表,进度百分比
+    public static function updatePercent($percent, $periodNum) {
+        $result = Period::updateAll(
+            ['PERF_PERCENT' => $percent], 
+            'PERIOD_NUM=:PERIOD_NUM', 
+            [':PERIOD_NUM' => $periodNum]
+        );
 
-    /**
-     * 所传月份所有已结算的期数
-     * @param $yearMonth
-     * @return array
-     */
-    public static function monthCalcAllPeriodNum($yearMonth){
-        $year = intval(substr($yearMonth, 0, 4));
-        $month = intval(substr($yearMonth, 4, 2));
-        $allPeriod = Period::find()->where('CALC_YEAR=:CALC_YEAR AND CALC_MONTH=:CALC_MONTH AND IS_CALCING=1', [':CALC_YEAR'=>$year, ':CALC_MONTH'=>$month])->select('PERIOD_NUM')->asArray()->all();
-        $result = [];
-        if($allPeriod){
-            foreach($allPeriod as $period){
-                $result[] = $period['PERIOD_NUM'];
-            }
-        }
         return $result;
     }
 
     /**
-     * 获取已结算的最大期数
-     * @return mixed
+     * 更新计算进度
      */
-    public static function calculatedMaxPeriodNum(){
-        return static::find()->where('IS_CALCULATED=1')->max('PERIOD_NUM');
-    }
-
-    /**
-     * 已挂网的最大期数
-     * @return mixed
-     */
-    public static function sentMaxPeriodNum(){
-        return static::find()->where('IS_SENT=1')->max('PERIOD_NUM');
-    }
-
-    /**
-     * 期数结束时间
-     * @param $periodNum
-     * @return int|mixed
-     */
-    public static function getEndTime($periodNum) {
-        $endTime = static::find()->where('PERIOD_NUM=:PERIOD_NUM', [':PERIOD_NUM' => $periodNum])->select('END_TIME')->asArray()->one();
-        return $endTime['END_TIME'] ?? 0;
-    }
-
-    /**
-     * 到年底的剩余月份
-     * @param null $periodNum
-     * @return int
-     * @throws Exception
-     */
-    public static function getMonthLeft($periodNum = null) {
-        $period = self::instance();
-        if ($periodNum) {
-            $nowMonth = $period->getMonth($periodNum);
-        } else {
-            $nowMonth = $period->getNowMonth();
-        }
-        return 12 - (int)$nowMonth + 1;
-    }
-
-    /**
-     * 起始期数和结束期数几个月
-     * @param $startPeriodNum
-     * @param $endPeriodNum
-     * @return int|string
-     */
-    public static function getMonthNum($startPeriodNum,$endPeriodNum){
-        return self::find()->select('CALC_MONTH')->groupBy('CALC_MONTH')->where('PERIOD_NUM>=:START_PERIOD AND PERIOD_NUM<=:END_PERIOD',[':START_PERIOD'=>$startPeriodNum,':END_PERIOD'=>$endPeriodNum])->count();
-    }
-
-    /**
-     * 从期数获取当前月的所有期
-     *
-     */
-    public static function getCurrentMonthPeriodByPeriodNum($periodNum){
-        $currentPeriod = self::getInfoByPeriodNum($periodNum);
-        $currentYear = $currentPeriod['CALC_YEAR'];
-        $currentMonth = $currentPeriod['CALC_MONTH'];
-        $periodsArray = self::findAllAsArray(['CALC_YEAR'=>$currentYear,'CALC_MONTH'=>$currentMonth]);
-        $periods = [];
-        foreach ($periodsArray as $p){
-            $periods[] = $p['PERIOD_NUM'];
-        }
-
-        return $periods;
-    }
-
-    // 奖金计算,更新业绩表,进度百分比
-    public static function updatePercent($percent, $periodNum) {
+    public static function updateCalcProcess($perpare, $periodNum) {
         $result = Period::updateAll(
-            ['PERF_PERCENT' => $percent], 
+            ['IS_PREPARE' => $perpare], 
             'PERIOD_NUM=:PERIOD_NUM', 
             [':PERIOD_NUM' => $periodNum]
         );