Procházet zdrojové kódy

个人和团队业绩

zxiansheng před 3 roky
rodič
revize
9d21201a48

+ 12 - 0
common/models/PerfMonthPrepare.php

@@ -151,6 +151,18 @@ class PerfMonthPrepare extends \common\components\ActiveRecord
         return $result;
     }
 
+    // 获取会员的月业绩信息
+    public static function getMonthPerfPrepare($userId,$calcMonth) {
+        $result = PerfMonthPrepare::findUseSlaves()
+        ->where(
+            'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', [':USER_ID' => $userId,':CALC_MONTH'=>$calcMonth]
+        )
+        ->asArray()
+        ->one();
+
+        return $result;
+    }
+
     /**
      * 操作日志记录条件
      * @return array

+ 22 - 16
frontendApi/modules/v1/controllers/BonusController.php

@@ -109,10 +109,7 @@ class BonusController extends BaseController {
         $period = Period::instance();
         $periodNum = $period->getNowPeriodNum();
         $month = $period->getNowMonth();
-        $data = PerfMonthPrepare::findUseSlaves()
-        ->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', [':USER_ID' => $userId,':CALC_MONTH'=>$month])
-        ->asArray()
-        ->one();
+        $data = PerfMonthPrepare::getMonthPerfPrepare($userId, $month);
         // PV_PCS 个人业绩  PV_PSS 月新增团队业绩  PV_PSS_TOTAL月累计团队业绩
         // 其中页面使用的是月新增团队业绩
         // 获取用信息
@@ -122,7 +119,7 @@ class BonusController extends BaseController {
             'name' => $userInfo['REAL_NAME'],
             'perf_status' => '0', // 0  未达标  1为已达标
             'user_perf' => 0, // 个人业绩
-            'team_perf' => 0, // 团队累计业绩
+            'team_perf' => 0, // 团队新增累计业绩
             'total_perf' => 0 // 合计业绩
         ];
         if (!empty($data)) {
@@ -136,23 +133,32 @@ class BonusController extends BaseController {
         $teamInfo = [];
         // 查询此用户的推荐(开拓)团队一级信息
         $relation = UserRelation::getChildrenWithDeepAndLayer($userId, 1, 1, $periodNum);
+        $userStatusFlag = false;
         if ($relation) {
             // 循环一级开拓用户
             foreach($relation as $v) {
                 // 获取此用户预计算月业绩
-                $relationPerf = PerfMonthPrepare::findUseSlaves()
-                ->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', [':USER_ID' => $userId,':CALC_MONTH'=>$month])
-                ->asArray()
-                ->one();
-                $teamInfo[]['number'] = $v['USER_NAME'];
-                $teamInfo[]['name'] = $v['REAL_NAME'];
-                $teamInfo[]['perf_status'] = 0;
-                $teamInfo[]['user_perf'] = 0;
-                $teamInfo[]['team_perf'] = 0;
-                $teamInfo[]['total_perf'] = 0;
+                $relationPerf = PerfMonthPrepare::getMonthPerfPrepare($v['USER_ID'], $month);
+                $teamInfo[]['perf_status'] = $relationPerf['PV_PCS'] >= 10000 ? 1 : 0;
+                if ($relationPerf['PV_PCS'] >= 10000) {
+                    $userStatusFlag = true;
+                    $teamInfo[]['number'] = '';
+                    $teamInfo[]['name'] = '';
+                    $teamInfo[]['user_perf'] = '';
+                    $teamInfo[]['team_perf'] = '';
+                    $teamInfo[]['total_perf'] = '';
+                } else {
+                    $teamInfo[]['number'] = $v['USER_NAME'];
+                    $teamInfo[]['name'] = $v['REAL_NAME'];
+                    $teamInfo[]['user_perf'] = $relationPerf['PV_PCS'];
+                    $teamInfo[]['team_perf'] = $relationPerf['PV_PSS'];
+                    $teamInfo[]['total_perf'] = $relationPerf['PV_PCS']+$relationPerf['PV_PSS'];
+                } 
             }
         }
-        
+        if ($userStatusFlag === true) {
+            $user['perf_status'] = 1;
+        }
         
         return static::notice(['user' => $user,'team'=>$teamInfo]);
     }