Browse Source

团队查询页面

theo 3 years ago
parent
commit
d322167c18

+ 5 - 0
common/models/PerfMonth.php

@@ -151,6 +151,11 @@ class PerfMonth extends \common\components\ActiveRecord
         return $result;
     }
 
+    public static function fetchMonthPerf($yearMonth, $userId){
+        $result = static::find()->select('*')->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', [':USER_ID'=>$userId, ':CALC_MONTH'=>$yearMonth])->asArray()->one();
+        return $result;
+    }
+
     // 校验业绩状态
     public static function checkStatus($pv) {
         if ($pv >= 1500) {

+ 18 - 3
common/models/Period.php

@@ -153,7 +153,7 @@ class Period extends \common\components\ActiveRecord
 
     // 通过期数,获取此期数据
     public static function getInfoByPeriodNum($periodNum) {
-        
+
         return static::findOneAsArray(['PERIOD_NUM'=>$periodNum]);
     }
 
@@ -565,13 +565,13 @@ class Period extends \common\components\ActiveRecord
     public function isLastSent($periodNum){
         $period = $this->setPeriodNum($periodNum-1);
         if ($period) {
-            if($period['IS_SENT'] == self::SEND_FINISH) { 
+            if($period['IS_SENT'] == self::SEND_FINISH) {
                 return true;
             } else {
                 return false;
             }
         }
-        
+
         return false;
     }
 
@@ -877,4 +877,19 @@ class Period extends \common\components\ActiveRecord
         if ($period['IS_PROCESSING'] == self::IS_PROCESSING) return true;
         return false;
     }
+
+    public static function checkPerf($periodNum){
+        $result = static::find()
+            ->where(
+                'PERIOD_NUM=:PERIOD_NUM ', [':PERIOD_NUM' => $periodNum]
+            )
+            ->asArray()
+            ->one();
+
+        if (isset($result['IS_PERFED']) && $result['IS_PERFED'] == 1) {
+            return true;
+        }
+
+        return false;
+    }
 }

+ 32 - 12
frontendApi/modules/v1/controllers/BonusController.php

@@ -114,7 +114,19 @@ class BonusController extends BaseController {
         $period = Period::instance();
         $periodNum = $period->getNowPeriodNum();
         $month = $period->getNowYearMonth();
+        // 判断此业绩期是否已经完成生成了预计算业绩单,生成完毕才能看到
+        $isPerfed = Period::checkPerf($periodNum);
+        if (!$isPerfed) {
+            return static::notice(['user' => [],'team'=>[]]);
+        }
+        // 判断当前时间,是否临近封期,否则隐藏
+        $nowTs = time();
+        $currentPeriodEnd = Period::getEndTime($periodNum);
+        if ($nowTs + 432000 <= $currentPeriodEnd || $currentPeriodEnd < $nowTs) {
+            return static::notice(['user' => [],'team'=>[]]);
+        }
         $userInfo = User::getEnCodeInfo($userId);
+        $data = PerfMonth::fetchMonthPerf($month, $userId);
         $user[0] = [
             'number' => $userInfo['USER_NAME'],
             'name' => $userInfo['REAL_NAME'],
@@ -124,6 +136,14 @@ class BonusController extends BaseController {
             'team_perf' => 0, // 团队新增累计业绩
             'total_perf' => 0 // 合计业绩
         ];
+        if (!empty($data)) {
+            $userCheck = PerfMonth::checkStatus($data['PV_PCS']+$data['PV_PSS']);
+            $user[0]['user_perf'] = $data['PV_PCS'];
+            $user[0]['team_perf'] = $userCheck ? '' : $data['PV_PSS'];
+            $user[0]['total_perf'] = $userCheck ? '' : $data['PV_PCS']+$data['PV_PSS'];
+            $user[0]['perf_status'] = $userCheck ? '1' : $user[0]['perf_status'];
+            $user[0]['perf_status_name'] = $userCheck ? '达标' : $user[0]['perf_status_name'];
+        }
         $teamInfo = [];
         $calcAt = PerfMonth::find()->select(['CREATED_AT'])->where('CALC_MONTH=:CALC_MONTH', ['CALC_MONTH'=>$month])->asArray()->one();
 
@@ -138,7 +158,7 @@ class BonusController extends BaseController {
             // 循环一级开拓用户
             foreach($relation as $k=>$v) {
                 // 获取此用户预计算月业绩
-                $relationPerf = PerfMonth::getMonthPerf($month, $v['USER_ID']);
+                $relationPerf = PerfMonth::fetchMonthPerf($month, $v['USER_ID']);
                 if (empty($relationPerf)) {
                     $relationPerf['PV_PCS'] = 0;
                     $relationPerf['PV_PSS'] = 0;
@@ -162,14 +182,14 @@ class BonusController extends BaseController {
                     $teamInfo[$k]['total_perf'] = $relationPerf['PV_PCS']+$relationPerf['PV_PSS'];
                     $teamInfo[$k]['perf_status'] = '0';
                     $teamInfo[$k]['perf_status_name'] = '不达标';
-                } 
+                }
             }
         }
         if ($userStatusFlag === true) {
             $user[0]['perf_status'] = '1';
             $user[0]['perf_status_name'] = '达标';
         }
-        
+
         return static::notice(['user' => $user,'team'=>$teamInfo,'calcAt' => $calcAt['CREATED_AT']]);
     }
 
@@ -396,19 +416,19 @@ class BonusController extends BaseController {
             // if ($sysConfig['openVIP']['VALUE']) {
             //     $data[] = ['name' => 'VIP奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_VIP'])];
             // }
-            
-            
+
+
             // if ($sysConfig['openXF']['VALUE']) {
             //     $data[] = ['name' => '消费奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_XF'])];
             // }
             // if ($sysConfig['openYJ']['VALUE']) {
             //     $data[] = ['name' => '业绩奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_YJ'])];
             // }
-            
+
             // if ($sysConfig['openGL']['VALUE']) {
             //     $data[] = ['name' => '管理奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_GL'])];
             // }
-            
+
             // if ($sysConfig['openJXS']['VALUE']) {
             //     $data[] = ['name' => '团队成长奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_STANDARD'])];
             // }
@@ -416,14 +436,14 @@ class BonusController extends BaseController {
 //            $data[] = ['name' => '零售奖', 'value' => Tool::formatPrice($calcBonus['BONUS_LS'])];
 //        }
 //        $data[]=['name'=>'责任业绩扣除','value'=>Tool::formatPrice($calcBonus['DEDUCT_ZR'])];
-            
-            
+
+
 //        $data[]=['name'=>'总奖金','value'=>Tool::formatPrice($calcBonus['BONUS_TOTAL'])];
-            
+
 //        if($sysConfig['openLX']['VALUE']) {
 //            $data[] = ['name' => '福利积分二', 'value' => Tool::formatPrice($calcBonus['BONUS_LX'])];
 //        }
-            
+
 //        $data[]=['name'=>'四市场新增业绩','value'=>Tool::formatFrontPerf($calcBonus['PV_4L'])];
 //        $data[]=['name'=>'五市场新增业绩','value'=>Tool::formatFrontPerf($calcBonus['PV_5L'])];
 //        $data[]=['name'=>'虚拟市场新增业绩','value'=>Tool::formatFrontPerf($calcBonus['PV_LS_TOUCH'])];
@@ -1113,4 +1133,4 @@ class BonusController extends BaseController {
         ]);
         return static::notice($data);
     }
-}
+}