Bläddra i källkod

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

brook 3 år sedan
förälder
incheckning
79c3fecdfe

+ 1 - 0
backendApi/config/urlManagerRules.php

@@ -572,6 +572,7 @@ return [
         'extraPatterns' => [
             'GET record-list/<periodNum>' => 'record-list',
             'GET auto-calc/<periodNum>' => 'auto-calc',
+            'GET auto-perf/<periodNum>' => 'auto-perf',
             'GET perf-order/<periodNum>' => 'perf-order',
             'GET init-data/<periodNum>' => 'init-data',
             'GET calc-perf-period/<periodNum>' => 'calc-perf-period',

+ 25 - 0
backendApi/modules/v1/controllers/CalcController.php

@@ -27,6 +27,31 @@ class CalcController extends BaseController
         return $behaviors;
     }
 
+    public function actionAutoPerf() {
+        $periodNum = \Yii::$app->request->get('periodNum');
+        if (!$periodNum) {
+            return static::notice('期数不存在', 400);
+        }
+        if (Period::isProcessing($periodNum)) {
+            return static::notice('有操作正在进行中请稍后', 400);
+        }
+        //设置计算进行中标识
+        Period::updatePeriodIsProcessing($periodNum, Period::IS_PROCESSING);
+        //设置自动计算标识
+        Period::updatePeriodIsAutoExec($periodNum, Period::MANUAL_EXEC_CALC);
+        //记录开始计算的时间
+        Period::updateAll(['START_EXEC_TIME' => time()], ['PERIOD_NUM' => $periodNum]);
+
+        $formModel = new PeriodForm();
+        $formModel->scenario = 'autoPerf';
+
+        if ($formModel->load(Yii::$app->request->get(), '') && $formModel->autoPerf()) {
+            return static::notice('自动计算已开始,请等待');
+        } else {
+            return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
+        }
+    }
+
     public function actionAutoCalc()
     {
         $periodNum = \Yii::$app->request->get('periodNum');

+ 25 - 7
backendEle/src/views/bonus/period.vue

@@ -67,6 +67,7 @@
         </el-table-column>
         <el-table-column fixed="right" label="Action" width="180"><!-- 操作 -->
           <template slot-scope="scope">
+            <el-button class="button" type="primary" @click.native="autoPerfHandle(scope.row.PERIOD_NUM)" >预计算</el-button>
             <el-button v-if="scope.row.IS_CAN_CLOSE && permission.hasPermission(`bonus/close-period`)" type="primary" class="button"
                        @click.native="closeHandle(scope.row)">
               Closure period<!-- 封期 -->
@@ -104,12 +105,13 @@
                   <el-row><el-button class="button" type="primary" @click.native="pullPerfPeriodHandle(currentPeriod)" >拉取期业绩</el-button></el-row>
                   <el-row><el-button class="button" type="primary" @click.native="calcBonusHandle(currentPeriod)" >计算奖金</el-button></el-row>
                   <el-row><el-button class="button" type="primary" @click.native="pullBonusHandle(currentPeriod)" >拉取奖金数据</el-button></el-row>
+<!--                  <el-row><el-button class="button" type="primary" @click.native="autoPerfHandle(currentPeriod)" >计算和拉取期业绩</el-button></el-row>-->
                 </div>
               </div>
             </el-dialog>
 
-            <el-dropdown size="small" trigger="click" v-if=false>
-<!--            <el-dropdown size="small" trigger="click" v-if="scope.row.BUTTON_IS_CAN">-->
+<!--            <el-dropdown size="small" trigger="click" v-if=false>-->
+            <el-dropdown size="small" trigger="click" v-if="scope.row.BUTTON_IS_CAN">
               <el-button type="primary" size="small" @click.stop="">
                 <!-- 操作该数据 -->Action<i class="el-icon-arrow-down el-icon--right"></i>
               </el-button>
@@ -368,8 +370,24 @@ export default {
       }).catch(response => {
       })
     },
+    autoPerfHandle (currentPeriod) {
+      this.$confirm('Confirm to calculate bonus data for the current period?', 'Hint', { // '确定对当前期进行生成业绩单操作?', '提示'
+        confirmButtonText: 'confirm', // 确定
+        cancelButtonText: 'cancel', // 取消
+        type: 'warning'
+      }).then(() => {
+        return network.getData(`calc/auto-perf/${currentPeriod}`)
+      }).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+        this.getDialogData(this.currentPage, this.pageSize)
+      }).catch(response => {
+      })
+    },
 
-    getDialogData() {
+    getDialogData () {
       let vueObj = this
       let paramsData = {
         page: this.currentDialogPage,
@@ -380,11 +398,11 @@ export default {
           vueObj.dialogData = response.list
           vueObj.dialogLoading = false;
         }).catch(response => {
-        this.$message({
-          message: response,
-          type: 'fail'
+          this.$message({
+            message: response,
+            type: 'fail'
+          })
         })
-      })
     },
 
     closeHandle (row) {

+ 4 - 3
common/components/SwooleAsyncTimer.php

@@ -48,11 +48,12 @@ class SwooleAsyncTimer extends SwooleAsyncTimerComponent implements SocketInterf
      */
     public function timerCallback($timerId, $server){
         // 自动封期
-        AutoClosePeriod::instance()->autoClose();
+//        AutoClosePeriod::instance()->autoClose();
         // 自动执行任务队列中的任务
         Queue::instance()->consumeTask();
         // 实时监听计算系统修改的period表字段
-        CalcConsole::listenCalcPeriod();
+//        CalcConsole::listenCalcPeriod();
+        CalcConsole::listenAutoPerfPeriod();
         return true;
     }
 
@@ -235,4 +236,4 @@ class SwooleAsyncTimer extends SwooleAsyncTimerComponent implements SocketInterf
             // 忽略错误
         }
     }
-}
+}

+ 41 - 1
common/helpers/bonus/Calc/CalcConsole.php

@@ -23,7 +23,9 @@ class CalcConsole extends BaseBusiness
                 break;
             }
         }
-
+if (empty($period)){
+    return true;
+}
         $businessPeriod = Period::find()->where(['PERIOD_NUM' => $period['PERIOD_NUM']])
             ->asArray()->one();
         //用户选择是否自动执行
@@ -94,6 +96,44 @@ class CalcConsole extends BaseBusiness
         return true;
     }
 
+    public static function listenAutoPerfPeriod()
+    {
+        $db        = self::CALC_DB_NAME;
+        $allPeriod = \Yii::$app->$db->createCommand("SELECT * FROM AR_PERIOD ")->queryAll();
+        $period    = [];
+        foreach ($allPeriod as $v) {
+            if ($v['IS_PREPARE'] > 0
+                //&& todo 补全状态
+            ) {
+                $period = $v;
+                break;
+            }
+        }
+        if (empty($period)){
+            return true;
+        }
+        if (2 == $period['IS_PREPARE'] && 1 == $period['IS_PERFED']) {
+            //拉取期业绩
+            CalcRecord::record($period['PERIOD_NUM'], '第' . $period['PERIOD_NUM'] . '期的业绩数据已生成');
+            CalcRecord::record($period['PERIOD_NUM'], '开始获取第' . $period['PERIOD_NUM'] . '期的期业绩数据');
+
+            Period::updatePeriodIsProcessing($period['PERIOD_NUM'], Period::IS_PROCESSING);
+            $res = (new PullPerfDataFromCalc($period['PERIOD_NUM']))->start();
+            if (200 == $res['code']) {
+                Period::updatePeriodIsProcessing($period['PERIOD_NUM'], Period::NOT_PROCESSING);
+                CalcRecord::record($period['PERIOD_NUM'], '第' . $period['PERIOD_NUM'] . '期的期业绩数据已获取55');
+                \Yii::$app->$db->createCommand()->update('AR_PERIOD', ['IS_PERFED' => 3], 'PERIOD_NUM=:PERIOD_NUM', ['PERIOD_NUM' => $period['PERIOD_NUM']])->execute();
+                return $res;
+            } else {
+                //结束计算状态
+                Period::updatePeriodIsProcessing($period['PERIOD_NUM'], Period::NOT_PROCESSING);
+                CalcRecord::record($period['PERIOD_NUM'], '第' . $period['PERIOD_NUM'] . '期的期业绩数据获取失败,原因:' . $res['msg']);
+                return $res;
+            }
+        }
+        return true;
+    }
+
     /**
      * 同步计算系统的计算进度日志到业务系统计算步骤表
      * @param $periodNum

+ 8 - 0
common/models/Order.php

@@ -163,6 +163,14 @@ class Order extends \common\components\ActiveRecord
         return $orders;
     }
 
+    /*
+     * 通过 期数和用户ID
+     * 查询当期订单
+     */
+    public static function fetchOrderCurrentPeriod($periodNum, $userId){
+        $orders = Order::find()->where("USER_ID = :USER_ID AND PERIOD_NUM = :PERIOD_NUM", [':USER_ID' => $userId,':PERIOD_NUM' => $periodNum]);
+        return $orders;
+    }
     public function getRecName()
     {
         return $this->hasOne(UserInfo::class, ['USER_ID' => 'USER_ID']);

+ 14 - 0
common/models/PerfMonth.php

@@ -151,6 +151,20 @@ 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) {
+            return true;
+        }
+
+        return false;
+    }
+
     /**
      * 操作日志记录条件
      * @return array

+ 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;
+    }
 }

+ 30 - 0
common/models/forms/PeriodForm.php

@@ -47,6 +47,7 @@ class PeriodForm extends Model
             'calc' => ['periodNum'],
             'send' => ['periodNum'],
             'autoClose' => ['periodNum'],
+            'autoPerf' => ['periodNum'],
         ];
         return array_merge($parentScenarios, $customScenarios);
     }
@@ -395,6 +396,35 @@ class PeriodForm extends Model
         return $model;
     }
 
+    /**
+     * 页面请求异步处理 自动计算
+     * @return string | null
+     */
+    public function autoPerf()
+    {
+        if (!$this->validate()) {
+            return null;
+        }
+//        // 把正在结算标记为真
+        $model = $this->_periodModel;
+//        $model->IS_CALCING    = 1;
+//        $model->CALC_ADMIN_ID = \Yii::$app->user->id;
+//        if (!$model->save()) {
+//            $this->addError('calc', Form::formatErrorsForApi($model->getErrors()));
+//            return null;
+//        }
+        // 异步处理添加任务
+        $settings      = \Yii::$app->params['swooleAsyncTimer'];
+        $bonusSettings = \Yii::$app->params['swooleBonusConfig'];
+        $settings      = array_merge($settings, $bonusSettings);
+        $taskKey       = \Yii::$app->swooleAsyncTimer->asyncHandle('calc/auto-perf', \Yii::$app->request->get(), $settings);
+        if ($taskKey === false) {
+            $this->addError('send', '请求失败');
+            return null;
+        }
+        return $model;
+    }
+
     /**
      * 页面请求异步处理 生成业绩单
      * @return string | null

+ 51 - 2
console/controllers/CalcController.php

@@ -36,7 +36,7 @@ class CalcController extends BaseController
             \Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($params['handleUserId'], "第{$params['periodNum']}期生成业绩单更新成功");
             return true;
         } else {
-            self::recordCalcAndProcessStatus($periodNum, '业绩单生成失败,原因:' . $res['msg'] ?? '');
+            self::recordCalcAndProcessStatus($periodNum, '业绩单生成失败,原因:' . substr($res['msg'],0,1000) ?? '');
             \Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($params['handleUserId'], "第{$params['periodNum']}期生成业绩单更新失败,原因:" . $res['msg'] ?? '', false);
             return false;
         }
@@ -60,7 +60,56 @@ class CalcController extends BaseController
             CalcRecord::record($periodNum, '业绩单已生成');
         } else {
             Period::updatePeriodIsProcessing($periodNum, Period::NOT_PROCESSING);
-            CalcRecord::record($periodNum, '第' . $periodNum . '期业绩单生成失败,原因:' . $res['msg']);
+            CalcRecord::record($periodNum, '第' . $periodNum . '期业绩单生成失败,原因:' . substr($res['msg'],0,100));
+            return false;
+        }
+
+        //推送基础数据
+        CalcRecord::record($periodNum, '开始推送基础数据');
+        $res = (new PushBaseDataToCalc($periodNum))->start();
+        if (200 == $res['code']) {
+            CalcRecord::record($periodNum, '基础数据完成推送');
+        } else {
+            Period::updatePeriodIsProcessing($periodNum, Period::NOT_PROCESSING);
+            CalcRecord::record($periodNum, '第' . $periodNum . '期基础数据推送失败,原因:' . $res['msg']);
+            return false;
+        }
+        //todo 完成需要修改状态
+
+        //通知结算系统生成期业绩
+        CalcRecord::record($periodNum, '开始生成' . $periodNum . '期的期业绩');
+        \Yii::$app->$db->createCommand()->update('AR_PERIOD', ['IS_PREPARE' => 1], 'PERIOD_NUM=' . $periodNum)->execute();
+        //todo 完成需要修改状态
+
+        //自动监听 拉取期业绩 并计算奖金
+//        (new PullPerfDataFromCalc($periodNum))->start();
+        //通知结算系统计算奖金
+//        \Yii::$app->$db->createCommand()->update('AR_PERIOD', ['IS_PREPARE' => 3], 'PERIOD_NUM=' . $periodNum)->execute();
+
+        //自动监听 计算完成 自动拉取奖金结果并修改状态
+//        (new PullCalcBonusData($period['PERIOD_NUM']))->start();
+        return true;
+    }
+
+    //自动计算业绩
+    public static function actionAutoPerf($taskKey): bool
+    {
+        $params    = Cache::getAsyncParams($taskKey);
+        $periodNum = $params['periodNum'] ?? 0;
+        //生成业绩单 状态已修改
+        CalcRecord::record($periodNum, '开始生成业绩单');
+        //重置业务系统的计算进度标识
+        \Yii::$app->db->createCommand()->update('AR_PERIOD', ['IS_PERFED' => 0, 'IS_CALCULATED' => 0], 'PERIOD_NUM=' . $periodNum)->execute();
+        //重置计算系统的计算进度标识
+        $db = CalcConsole::CALC_DB_NAME;
+        \Yii::$app->$db->createCommand()->update('AR_PERIOD', ['IS_PREPARE' => 0, 'IS_PERFED' => 0, 'IS_CALCULATED' => 0], 'PERIOD_NUM=' . $periodNum)->execute();
+
+        $res = (new GeneratePerfOrder($periodNum))->start();
+        if (200 == $res['code']) {
+            CalcRecord::record($periodNum, '业绩单已生成');
+        } else {
+            Period::updatePeriodIsProcessing($periodNum, Period::NOT_PROCESSING);
+            CalcRecord::record($periodNum, '第' . $periodNum . '期业绩单生成失败,原因:' . substr($res['msg'],0,100));
             return false;
         }
 

+ 3 - 2
frontendApi/config/menu.php

@@ -81,6 +81,7 @@ return [
             ['name'=>'My account', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'index', 'routePath'=>'bonus/index', 'show'=>1,],//我的账户
 //            ['name'=>'最新奖金', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'new', 'routePath'=>'bonus/new', 'show'=>1,'allow'=>'newBonusSwitch'],
             ['name'=>'My bonus', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'other', 'routePath'=>'bonus/other', 'show'=>1,'allow'=>'pastBonusSwitch'],//往期奖金
+            ['name'=>'Team inquiry', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'teams', 'routePath'=>'bonus/teams', 'show'=>1,], // 团队查询
             ['name'=>'Historical cumulative bonus', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'other', 'routePath'=>'bonus/historical-cumulative-bonus', 'show'=>1,'allow'=>'pastBonusSwitch'],//历史累积奖金
             //['name'=>'实时业绩', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'real-time-perf', 'routePath'=>'bonus/real-time-perf', 'show'=>1,],
            // ['name'=>'房产积分', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'fc-point', 'routePath'=>'bonus/fc-point', 'show'=>1,],
@@ -118,7 +119,7 @@ return [
         'routePath'=>'article',
         'show'=>1,
         'child'=>[
-			
+
         ]
     ],
 //    'message'=>[
@@ -147,4 +148,4 @@ return [
             ['name'=>'Shipping Address', 'class'=>'', 'icon'=>'', 'controller'=>'config', 'action'=>'receive-address-list', 'routePath'=>'config/receive-address-list', 'show'=>1,],//收货地址管理
         ]
     ],
-];
+];

+ 1 - 0
frontendApi/config/urlManagerRules.php

@@ -142,6 +142,7 @@ return [
             'GET index' => 'index',
             'GET wallet-flow' => 'wallet-flow',
             'GET new' => 'new',
+            'GET teams' => 'teams',
             'GET other' => 'other',
             'GET real-time-perf' => 'real-time-perf',
             'GET flow-bt' => 'flow-bt',

+ 99 - 9
frontendApi/modules/v1/controllers/BonusController.php

@@ -35,6 +35,7 @@ use common\models\FlowExchangePoints;
 use common\models\ScoreMonth;
 use common\models\UserBonus;
 use common\models\UserWallet;
+use common\models\UserRelation;
 use frontendApi\modules\v1\models\User;
 
 class BonusController extends BaseController {
@@ -103,6 +104,95 @@ class BonusController extends BaseController {
         return static::notice(['wallet' => $wallet,'dealSwitch'=>$dealSwitch]);
     }
 
+    /**
+     * 团队查询
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionTeams() {
+        $userId = \Yii::$app->user->id;
+        $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'],
+            'user_perf' => 0, // 个人业绩
+            'team_perf' => 0, // 团队新增累计业绩
+            'total_perf' => 0, // 合计业绩
+            'perf_status' => '0', // 0  未达标  1为已达标
+            'perf_status_name' => 'Fail',
+        ];
+        if (!empty($data)) {
+            $userCheck = PerfMonth::checkStatus($data['PV_PCS']+$data['PV_PSS']);
+            $user[0]['user_perf'] = $data['PV_PCS'];
+            $user[0]['team_perf'] = $data['PV_PSS'];
+            $user[0]['total_perf'] = $data['PV_PCS']+$data['PV_PSS'];
+            $user[0]['perf_status'] = $userCheck ? '1' : $user[0]['perf_status'];
+            $user[0]['perf_status_name'] = $userCheck ? 'Pass' : $user[0]['perf_status_name'];
+        }
+        $teamInfo = [];
+        $calcAt = PerfMonth::find()->select(['CREATED_AT'])->where('CALC_MONTH=:CALC_MONTH', ['CALC_MONTH'=>$month])->asArray()->one();
+
+        if(!$calcAt){
+            $periodStartTime = $period->nowPeriodArr['START_TIME'];
+            return static::notice(['user' => $user,'team'=>[],'calcAt' => $periodStartTime]);
+        }
+        // 查询此用户的推荐(开拓)团队一级信息
+        $relation = UserRelation::getChildrenWithDeepAndLayer($userId, 1, 1, $periodNum);
+        $userStatusFlag = false;
+        if ($relation) {
+            // 循环一级开拓用户
+            foreach($relation as $k=>$v) {
+                // 获取此用户预计算月业绩
+                $relationPerf = PerfMonth::fetchMonthPerf($month, $v['USER_ID']);
+                if (empty($relationPerf)) {
+                    $relationPerf['PV_PCS'] = 0;
+                    $relationPerf['PV_PSS'] = 0;
+                }
+                $relationCheck = PerfMonth::checkStatus($relationPerf['PV_PCS']+$relationPerf['PV_PSS']);
+                $teamInfo[]['perf_status'] = $relationCheck ? '1' : '0';
+                if ($relationCheck) {
+                    $userStatusFlag = true; // 只要有一个达标,则个人就达标
+                    $teamInfo[$k]['number'] = $v['USER_NAME'];
+                    $teamInfo[$k]['name'] = $v['REAL_NAME'];
+                    $teamInfo[$k]['user_perf'] = $relationPerf['PV_PCS'];
+                    $teamInfo[$k]['team_perf'] = $relationPerf['PV_PSS'];
+                    $teamInfo[$k]['total_perf'] = $relationPerf['PV_PCS']+$relationPerf['PV_PSS'];
+                    $teamInfo[$k]['perf_status'] = '1';
+                    $teamInfo[$k]['perf_status_name'] = 'Pass';
+                } else {
+                    $teamInfo[$k]['number'] = $v['USER_NAME'];
+                    $teamInfo[$k]['name'] = $v['REAL_NAME'];
+                    $teamInfo[$k]['user_perf'] = $relationPerf['PV_PCS'];
+                    $teamInfo[$k]['team_perf'] = $relationPerf['PV_PSS'];
+                    $teamInfo[$k]['total_perf'] = $relationPerf['PV_PCS']+$relationPerf['PV_PSS'];
+                    $teamInfo[$k]['perf_status'] = '0';
+                    $teamInfo[$k]['perf_status_name'] = 'Fail';
+                }
+            }
+        }
+        if ($userStatusFlag === true) {
+            $user[0]['perf_status'] = '1';
+            $user[0]['perf_status_name'] = 'Pass';
+        }
+
+        return static::notice(['user' => $user,'team'=>$teamInfo,'calcAt' => $calcAt['CREATED_AT']]);
+    }
+
     /**
      * 交易记录
      * @return mixed
@@ -326,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'])];
             // }
@@ -346,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'])];
@@ -1043,4 +1133,4 @@ class BonusController extends BaseController {
         ]);
         return static::notice($data);
     }
-}
+}

+ 1 - 0
frontendEle/package.json

@@ -22,6 +22,7 @@
     "countup.js": "^1.9.3",
     "echarts": "^4.1.0",
     "element-ui": "^2.13.0",
+    "moment": "^2.29.4",
     "font-awesome": "^4.7.0",
     "nix-tinymce": "^1.0.7",
     "v-charts": "^1.16.20",

+ 2 - 0
frontendEle/src/main.js

@@ -10,7 +10,9 @@ import router from './router'
 import axios from './utils/axiosPlugin'
 import errorInfo from './utils/errorCode'
 import webSocketService from './utils/websocket';
+import moment from 'moment'
 
+Vue.prototype.$moment = moment
 Vue.use(ElementUI,{locale})
 Vue.prototype.$webSocket = webSocketService;
 

+ 13 - 1
frontendEle/src/router/index.js

@@ -480,7 +480,19 @@ export const constantRouterMap = [
             {title: 'Bonus management', path: '/bonus/index'}
           ]
         }
-      }
+      },
+      {
+        path: '/bonus/teams',
+        component: _import('bonus/teams'),
+        name: 'bonus_teams',
+        meta: {
+          title: 'Team inquiry', // 团队查询
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'},
+            {title: 'Bonus management', path: '/bonus/index'},
+          ],
+        },
+      },
 
     ]
   },

+ 252 - 0
frontendEle/src/views/bonus/teams.vue

@@ -0,0 +1,252 @@
+<template>
+  <div v-loading="loading">
+    <el-table
+    border
+    :data="userData"
+    style="width: 100%"
+    :cell-style="tableCellStyle"
+    >
+    <el-table-column label="Personal details"><!-- 个人情况 -->
+      <el-table-column
+      type="index"
+      :index="indexMethod"
+          width="60px"
+          label=""
+          >
+        </el-table-column>
+        <el-table-column
+          prop="number"
+          label="Member code"
+          ><!-- 会员编号 -->
+        </el-table-column>
+        <el-table-column
+          prop="name"
+          label="Member name"
+          ><!-- 会员姓名 -->
+        </el-table-column>
+        <el-table-column
+          prop="perf_status_name"
+          label="Status"
+          ><!-- 状态 -->
+        </el-table-column>
+        <el-table-column
+          prop="user_perf"
+          label="Personal BV"
+          ><!-- 个人业绩 -->
+        </el-table-column>
+         <el-table-column
+          prop="team_perf"
+          label="PGS"
+          ><!-- 累计业绩 -->
+        </el-table-column>
+         <el-table-column
+          prop="total_perf"
+          label="Total BV"
+          ><!-- 合计 -->
+        </el-table-column>
+      </el-table-column>
+
+  </el-table>
+
+  <el-table
+    border
+    :data="tableData"
+    style="width: 100%;margin-top:20px;"
+    :cell-style="tableCellStyle"
+   >
+    <el-table-column label="Team details"><!-- 团队情况 -->
+      <el-table-column
+      type="index"
+      :index="indexMethod"
+          width="60px"
+          label=""
+          >
+        </el-table-column>
+         <el-table-column
+          prop="number"
+          label="Member code"
+          ><!-- 会员编号 -->
+        </el-table-column>
+        <el-table-column
+          prop="name"
+          label="Member name"
+          ><!-- 会员姓名 -->
+        </el-table-column>
+        <el-table-column
+          class="dsdd"
+          prop="perf_status_name"
+          label="Status"
+          ><!-- 状态 -->
+        </el-table-column>
+        <el-table-column
+          prop="user_perf"
+          label="Personal BV"
+          ><!-- 个人业绩 -->
+        </el-table-column>
+         <el-table-column
+          prop="team_perf"
+          label="PGS"
+          ><!-- 累计业绩 -->
+        </el-table-column>
+         <el-table-column
+          prop="total_perf"
+          label="Total BV"
+          ><!-- 合计 -->
+        </el-table-column>
+      </el-table-column>
+
+  </el-table>
+  <el-descriptions  :column="2"  >
+  <el-descriptions-item label="Latest calculation time" >{{getWatTime(calcTime)}}</el-descriptions-item><!-- 最新计算时间 -->
+</el-descriptions>
+  </div>
+</template>
+
+<script>
+import network from '@/utils/network'
+import tool from '@/utils/tool'
+import Pagination from '@/components/Pagination'
+
+export default {
+  name: 'bonus_teams',
+  components: {Pagination},
+  mounted () {
+    this.getData()
+  },
+  data () {
+    return {
+      calcTime: '',
+      userData: [],
+      tableData: [],
+      allData: null,
+      walletData: null,
+      dealSwitch: null,
+      loading: true,
+      dialogFlowVisible: false,
+      currentPage: 1,
+      totalPages: 1,
+      totalCount: 1,
+      pageSize: 20,
+      walletType: 'bonus',
+      walletName: '',
+      dialogLoading: false,
+      tool: tool,
+      createAt: '',
+      dealType: null,
+      remark: '',
+      dealTypes: []
+    }
+  },
+  methods: {
+    tableCellStyle ({row, column, rowIndex, columnIndex}) {
+      // console.log(row,column,rowIndex,columnIndex)
+      if (row.perf_status === '0' && columnIndex === 3) {
+        return 'background-color:rgb(225, 25, 98);font-weight:bold'
+      } else if (row.perf_status === '1' && columnIndex === 3) {
+        return 'background-color:rgb(31, 156, 18);font-weight:bold'
+      }
+    },
+    indexMethod (index) {
+      return index + 1
+    },
+    getData () {
+      let vueObj = this
+      vueObj.loading = true
+      network.getData('bonus/teams').then(response => {
+        this.userData = response.user
+        this.tableData = response.team
+        this.calcTime = response.calcAt
+        console.log(this.calcTime)
+        vueObj.loading = false
+      }).catch(response => {
+        vueObj.loading = false
+      })
+    },
+    showFlow (walletType, walletName) {
+      let vueObj = this
+      this.$message({
+        message: '正在获取数据',
+        type: 'info'
+      })
+      this.walletType = walletType
+      this.walletName = walletName
+      vueObj.dialogFlowVisible = true
+      vueObj.dialogLoading = true
+      this.handleFilterClear()
+    },
+    getWatTime (ts) {
+      ts = parseInt(ts)
+      if (ts) {
+        return this.$moment(ts * 1000).utcOffset('+0100').format('YYYY-MM-DD HH:mm:ss')
+      } else {
+        return ''
+      }
+    }
+  }
+}
+
+</script>
+<style scoped>
+  .leo-filter {
+    padding: 0 0 15px 0;
+  }
+
+  .leo-filter .filter-hidden {
+    display: none;
+  }
+
+  .filter-item {
+    margin-right: 10px;
+  }
+
+  @media (min-width: 768px) {
+    .leo-filter {
+    }
+
+    .leo-filter .filter-item {
+      display: inline-block;
+      max-width: 200px;
+    }
+
+    .leo-filter .filter-item.filter-date-month-picker {
+      display: inline-block;
+      max-width: 220px;
+    }
+
+    .leo-filter .filter-item.filter-date-range-picker {
+      display: inline-block;
+      max-width: 380px;
+    }
+
+    .leo-filter .filter-item.filter-filter-btn {
+      height: 38px;
+      width: 80px;
+    }
+
+    .leo-filter .filter-hidden {
+      display: none;
+    }
+  }
+</style>
+<style scoped>
+.dialog-footer:after{content: '';
+  clear: both;display: table;
+}
+.el-table .warning-row {
+  background: oldlace;
+}
+
+.el-table .success-row {
+  background: #f0f9eb;
+    /* color:rgb(225, 25, 98)   */
+}
+.el-descriptions {
+  margin-top:20px;
+}
+/deep/ .el-descriptions-item__container {
+  margin-top:10px;
+}
+/deep/ .el-descriptions-item__label.has-colon {
+  margin-left:10px;
+}
+</style>

+ 18 - 0
sql/upgrade/2175.sql

@@ -0,0 +1,18 @@
+alter table AR_PERIOD add IS_PROCESSING tinyint(1) not null DEFAULT 0  COMMENT '是否计算中';
+
+alter table AR_PERIOD add AUTO_EXEC tinyint(1) not null DEFAULT 0 COMMENT  '一键计算标识';
+
+alter table AR_PERIOD add START_EXEC_TIME int(11) unsigned  not null DEFAULT 0  COMMENT '开始计算的时间';
+alter table AR_PERF_ORDER add PAY_TYPE varchar(32) not null DEFAULT ''  COMMENT '支付方式 cash现金支付  point复消点数  exchange兑换点数';
+
+ALTER TABLE `AR_PERIOD`  ADD COLUMN `IS_PREPARE` tinyint(1) NOT NULL DEFAULT 0 AFTER `IS_PROCESSING`;
+
+update AR_CONFIG set VALUE='1' where CONFIG_NAME='openGL';
+
+CREATE TABLE `AR_CALC_RECORD` (
+  `ID` varchar(32) NOT NULL,
+  `PERIOD_NUM` int(11) NOT NULL,
+  `TEXT` varchar(5000) DEFAULT NULL,
+  `CREATED_AT` int(10) NOT NULL,
+  PRIMARY KEY (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;