root 3 年 前
コミット
a09cfb94d7

+ 1 - 0
frontendApi/config/menu.php

@@ -73,6 +73,7 @@ return [
         'show'=>1,
         'child'=>[
             ['name'=>'我的账户', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'index', 'routePath'=>'bonus/index', 'show'=>1,],
+            ['name'=>'团队查询', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'search', 'routePath'=>'bonus/search', 'show'=>1,],
             ['name'=>'最新奖金', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'new', 'routePath'=>'bonus/new', 'show'=>1,'allow'=>'newBonusSwitch'],
             ['name'=>'往期奖金', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'other', 'routePath'=>'bonus/other', 'show'=>1,'allow'=>'pastBonusSwitch'],
             //['name'=>'实时业绩', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'real-time-perf', 'routePath'=>'bonus/real-time-perf', 'show'=>1,],

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

@@ -29,8 +29,10 @@ use common\models\Period;
 use common\models\DecRole;
 use common\models\EmployLevel;
 use common\models\FlowExchangePoints;
+use common\models\PerfMonthPrepare;
 use common\models\ScoreMonth;
 use common\models\UserBonus;
+use common\models\UserRelation;
 use common\models\UserWallet;
 use frontendApi\modules\v1\models\User;
 
@@ -94,6 +96,67 @@ class BonusController extends BaseController {
         return static::notice(['wallet' => $wallet,'dealSwitch'=>$dealSwitch]);
     }
 
+    /**
+     * 团队查询
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionSearch() {
+        $userId = \Yii::$app->user->id;
+        // 查询此用户,月业绩
+        //期数显示
+        // 达标规则,小组底下有一个大于等于一万.或者个人情况里的合计大于等于一万
+        $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();
+        // PV_PCS 个人业绩  PV_PSS 月新增团队业绩  PV_PSS_TOTAL月累计团队业绩
+        // 其中页面使用的是月新增团队业绩
+        // 获取用信息
+        $userInfo = User::getEnCodeInfo($userId);
+        $user = [
+            'number' => $userInfo['USER_NAME'],
+            'name' => $userInfo['REAL_NAME'],
+            'perf_status' => '0', // 0  未达标  1为已达标
+            'user_perf' => 0, // 个人业绩
+            'team_perf' => 0, // 团队累计业绩
+            'total_perf' => 0 // 合计业绩
+        ];
+        if (!empty($data)) {
+            $user['user_perf'] = $data['PV_PCS'];
+            $user['team_perf'] = $data['PV_PSS'];
+            $user['total_perf'] = $data['PV_PCS']+$data['PV_PSS'];
+            if ($user['total_perf'] >= 10000) {
+                $user['perf_status'] = '1';
+            }
+        }
+        $teamInfo = [];
+        // 查询此用户的推荐(开拓)团队一级信息
+        $relation = UserRelation::getChildrenWithDeepAndLayer($userId, 1, 1, $periodNum);
+        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;
+            }
+        }
+        
+        
+        return static::notice(['user' => $user,'team'=>$teamInfo]);
+    }
+
     /**
      * 交易记录
      * @return mixed