Explorar o código

会员必须等业绩计算完成才能查看

root %!s(int64=3) %!d(string=hai) anos
pai
achega
bc5f082f5a

+ 3 - 0
common/helpers/bonus/PreparePerfCalc.php

@@ -177,6 +177,9 @@ class PreparePerfCalc {
             echo('业绩结算全部完成,共耗时:' . round($t10 - $t9, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
         } catch (\Exception $e) {
             $this->errorCalcTask();
+            file_put_contents('error_test.txt', var_export([
+                'err' => $e->getMessage()
+            ],true));
             $this->addError('calc', $e->getMessage());
             return false;
         }

+ 16 - 0
common/models/PeriodPrepare.php

@@ -124,4 +124,20 @@ class PeriodPrepare extends \common\components\ActiveRecord
             'CREATED_AT' => '创建时间',
         ];
     }
+
+    // 获取此业绩是否已计算完成,只有计算完成,计算完成才给用户展示
+    public static function isPerfed($periodNum) {
+        $result = PeriodPrepare::findUseSlaves()
+        ->where(
+            'PERIOD_NUM=:PERIOD_NUM ', [':PERIOD_NUM' => $periodNum]
+        )
+        ->asArray()
+        ->one();
+
+        if (isset($result['IS_PERFED']) && $result['IS_PERFED'] == 1) {
+            return true;
+        }
+
+        return false;
+    }
 }

+ 6 - 0
frontendApi/modules/v1/controllers/BonusController.php

@@ -30,6 +30,7 @@ use common\models\DecRole;
 use common\models\EmployLevel;
 use common\models\FlowExchangePoints;
 use common\models\PerfMonthPrepare;
+use common\models\PeriodPrepare;
 use common\models\ScoreMonth;
 use common\models\UserBonus;
 use common\models\UserRelation;
@@ -113,6 +114,11 @@ class BonusController extends BaseController {
         if ($w != '0' || $isCalcMonth != 1) {
             return static::notice(['user' => [],'team'=>[]]);
         }
+        // 判断此业绩期是否已经完成生成了预计算业绩单,生成完毕才能看到
+        $isPerfed = PeriodPrepare::isPerfed($periodNum);
+        if (!$isPerfed) {
+            return static::notice(['user' => [],'team'=>[]]);
+        }
         
         // 达标规则,小组底下有一个大于等于一万.或者个人情况里的合计大于等于一万
         $data = PerfMonthPrepare::getMonthPerfPrepare($userId, $month);