Przeglądaj źródła

Merge branch 'master' into feature/2034-brook-calcBonus

brook 3 lat temu
rodzic
commit
108dafb978
1 zmienionych plików z 20 dodań i 10 usunięć
  1. 20 10
      common/helpers/bonus/Calc/CalcConsole.php

+ 20 - 10
common/helpers/bonus/Calc/CalcConsole.php

@@ -16,19 +16,22 @@ class CalcConsole extends BaseBusiness
         $allPeriod = \Yii::$app->$db->createCommand("SELECT * FROM AR_PERIOD order by PERIOD_NUM desc")->queryAll();
         $period    = [];
         foreach ($allPeriod as $v) {
-            if ($v['IS_PREPARE'] > 0
-                && $v['IS_SENT'] === 0 //未挂网
-            ) {
+            if ($v['IS_PREPARE'] > 0) {
                 $period = $v;
                 break;
             }
         }
-
-        if (empty($period)){
+        if (empty($period)) {
             return true;
         }
         $businessPeriod = Period::find()->where(['PERIOD_NUM' => $period['PERIOD_NUM']])
             ->asArray()->one();
+
+        if ($businessPeriod['SEND_STARTED_AT'] > 0 || $businessPeriod['IS_SENT'] > 0) {
+            //开始挂网 或者 已挂网 则直接返回
+            return true;
+        }
+
         //用户选择是否自动执行
         $autoExec             = $businessPeriod['AUTO_EXEC'] > Period::MANUAL_EXEC_CALC;
         $businessIsCalculated = $businessPeriod['IS_CALCULATED'] == Period::CALCULATE_FINISH;
@@ -100,19 +103,26 @@ class CalcConsole extends BaseBusiness
     public static function listenAutoPerfPeriod()
     {
         $db        = self::CALC_DB_NAME;
-        $allPeriod = \Yii::$app->$db->createCommand("SELECT * FROM AR_PERIOD ")->queryAll();
+        $allPeriod = \Yii::$app->$db->createCommand("SELECT * FROM AR_PERIOD order by PERIOD_NUM desc")->queryAll();
         $period    = [];
         foreach ($allPeriod as $v) {
-            if ($v['IS_PREPARE'] > 0
-                //&& todo 补全状态
-            ) {
+            if ($v['IS_PREPARE'] > 0) {
                 $period = $v;
                 break;
             }
         }
-        if (empty($period)){
+        if (empty($period)) {
             return true;
         }
+
+        $businessPeriod = Period::find()->where(['PERIOD_NUM' => $period['PERIOD_NUM']])
+            ->asArray()->one();
+
+        if ($businessPeriod['SEND_STARTED_AT'] > 0 || $businessPeriod['IS_SENT'] > 0) {
+            //开始挂网 或者 已挂网 则直接返回
+            return true;
+        }
+
         if (2 == $period['IS_PREPARE'] && 1 == $period['IS_PERFED']) {
             //拉取期业绩
             CalcRecord::record($period['PERIOD_NUM'], '第' . $period['PERIOD_NUM'] . '期的预计算业绩数据已生成');