kevin_zhangl 3 лет назад
Родитель
Сommit
6203169d1c

+ 1 - 0
backendApi/config/menu.php

@@ -256,6 +256,7 @@ return [
 //            ['name'=>'管理奖贴向上追溯', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'trace-up-gl', 'routePath'=>'bonus/trace-up-gl', 'show'=>1,],
 //            ['name'=>'管理奖向上追溯导出', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'trace-up-gl-export', 'routePath'=>'bonus/trace-up-gl-export', 'show'=>0,],
             ['name'=>'用户业绩', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'user-perf', 'routePath'=>'bonus/user-perf', 'show'=>1,],
+            ['name'=>'业绩调整', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'perf-adjustment', 'routePath'=>'bonus/perf-adjustment', 'show'=>1,],
 //            ['name'=>'荣衔业绩', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'yc-perf', 'routePath'=>'bonus/yc-perf', 'show'=>1,],
             ['name'=>'达标业绩', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'perf-standard', 'routePath'=>'bonus/perf-standard', 'show'=>1,],
             ['name'=>'达标业绩导出', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'perf-standard-export', 'routePath'=>'bonus/perf-standard-export', 'show'=>0,],

+ 1 - 0
backendApi/config/urlManagerRules.php

@@ -403,6 +403,7 @@ return [
             'GET yc-perf' => 'yc-perf',
             'GET period-perf' => 'period-perf',
             'GET period-perf-export' => 'period-perf-export',
+            'GET,POST perf-adjustment' => 'perf-adjustment',
         ],
     ],
     [

+ 42 - 0
backendApi/modules/v1/controllers/BonusController.php

@@ -46,6 +46,7 @@ use common\helpers\user\Info;
 use common\helpers\user\Perf;
 use common\models\CalcBonus;
 use common\models\CFLXAudit;
+use common\models\forms\PerfAdjustmentForm;
 use common\models\forms\ResendQYForm;
 use common\models\forms\SendCFAndLXForm;
 use common\models\PerfMonth;
@@ -55,6 +56,7 @@ use common\models\ResendQYAudit;
 use common\models\User;
 use common\models\UserInfo;
 use common\models\UserNetwork;
+use common\models\UserPerf;
 use Yii;
 use common\helpers\Form;
 use common\models\Config;
@@ -2824,4 +2826,44 @@ class BonusController extends BaseController {
         }
         return static::notice('导出开始,请到文件管理-导出文件查看');
     }
+
+    /**
+     * 查询安置网下级会员和业绩、修改业绩
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionPerfAdjustment()
+    {
+        // 查询业绩
+        if (\Yii::$app->request->isGet) {
+            $memberCode = Yii::$app->request->get('memberCode');
+            $userId = Info::getUserIdByUserName(trim($memberCode));
+
+            $perfList = [];
+            // 查询传入会员的安置网下级
+            $memberList = UserNetwork::getFirstFloorChildren($userId);
+            if ($memberList) {
+                foreach ($memberList as $member) {
+                    // 查询会员的业绩
+                    $perfMarket = UserPerf::getPerfMarket($member['USER_ID']);
+                    // 查询会员名
+                    $perfMarket['USER_NAME'] = Info::getUserNameByUserId($member['USER_ID']);
+                    $perfList[] = $perfMarket;
+                }
+            }
+
+            return static::notice(['allData' => $perfList]);
+        } else if (\Yii::$app->request->isPost) {
+            $formModel = new PerfAdjustmentForm();
+            $formModel->scenario = 'perfAdjustment';
+            $post = \Yii::$app->request->post();
+            if ($formModel->load($post, '') && $formModel->perfAdjustment()) {
+                return static::notice('成功');
+            } else {
+                return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
+            }
+        } else {
+            return static::notice('非法请求', 400);
+        }
+    }
 }

+ 12 - 0
backendEle/src/router/index.js

@@ -1200,6 +1200,18 @@ export const constantRouterMap = [
           ],
         },
       },
+      {
+        path: '/bonus/perf-adjustment',
+        component: _import('bonus/perf-adjustment'),
+        name: 'bonus-perf-adjustment',
+        meta: {
+          title: '业绩调整',
+          breadcrumb: [
+            {title: '首页', path: '/dashboard/index'},
+            {title: '奖金管理', path: '/bonus/period'},
+          ],
+        },
+      },
       {
         path: '/bonus/score-month',
         component: _import('bonus/score-month'),

+ 177 - 0
backendEle/src/views/bonus/perf-adjustment.vue

@@ -0,0 +1,177 @@
+<template>
+  <div v-loading="loading">
+    <div class="white-box">
+      <div class="filter-user" @keyup.enter="getData()">
+        <el-input v-model="memberCode" size="small" style="width:400px;" prefix-icon="el-icon-user-solid">
+          <template slot="prepend">会员名字</template>
+        </el-input>
+        <el-button type="primary" icon="el-icon-search" size="small" @click="getData()">确定</el-button>
+      </div>
+
+      <div style="margin-top: 45px;">
+        <el-row>
+          <el-col :span="8" v-show="show" v-for="(item, index) in tableList" :key="index">
+            <div class="grid-content bg-purple" style="width: 100%;">
+              <el-card class="box-card" shadow="hover" style="margin: 15px;">
+                <el-form :model="item" status-icon  label-width="100px" width="100%" class="demo-ruleForm">
+                  <el-form-item label="会员名字" prop="USER_NAME">
+                    <el-input type="text" size="small" v-model="item.USER_ID" v-show="false"></el-input>
+                    <el-input type="text" size="small" v-model="item.USER_NAME" readonly prefix-icon="el-icon-user"></el-input>
+                  </el-form-item>
+
+                  <el-divider><i class="el-icon-s-data"></i> 一市场业绩</el-divider>
+                  <el-form-item label="综合结余" prop="SURPLUS_1L">
+                    <el-input type="text" size="small" v-model="item.SURPLUS_1L" autocomplete="off" prefix-icon="el-icon-s-data"></el-input>
+                  </el-form-item>
+                  <el-form-item label="首单结余" prop="SURPLUS_1L_ZC">
+                    <el-input type="text" size="small" v-model="item.SURPLUS_1L_ZC" autocomplete="off" prefix-icon="el-icon-s-data"></el-input>
+                  </el-form-item>
+                  <el-form-item label="复消结余" prop="SURPLUS_1L_FX">
+                    <el-input type="text" size="small" v-model="item.SURPLUS_1L_FX" autocomplete="off" prefix-icon="el-icon-s-data"></el-input>
+                  </el-form-item>
+
+                  <el-divider><i class="el-icon-s-data"></i> 二市场业绩</el-divider>
+                  <el-form-item label="综合结余" prop="SURPLUS_2L">
+                    <el-input type="text" size="small" v-model="item.SURPLUS_2L" autocomplete="off" prefix-icon="el-icon-s-data"></el-input>
+                  </el-form-item>
+                  <el-form-item label="首单结余" prop="SURPLUS_2L_ZC">
+                    <el-input type="text" size="small" v-model="item.SURPLUS_2L_ZC" autocomplete="off" prefix-icon="el-icon-s-data"></el-input>
+                  </el-form-item>
+                  <el-form-item label="复消结余" prop="SURPLUS_2L_FX">
+                    <el-input type="text" size="small" v-model="item.SURPLUS_2L_FX" autocomplete="off" prefix-icon="el-icon-s-data"></el-input>
+                  </el-form-item>
+
+                  <el-divider><i class="el-icon-s-data"></i> 三市场业绩</el-divider>
+                  <el-form-item label="综合结余" prop="SURPLUS_3L">
+                    <el-input type="text" size="small" v-model="item.SURPLUS_3L" autocomplete="off" prefix-icon="el-icon-s-data"></el-input>
+                  </el-form-item>
+                  <el-form-item label="首单结余" prop="SURPLUS_3L_ZC">
+                    <el-input type="text" size="small" v-model="item.SURPLUS_3L_ZC" autocomplete="off" prefix-icon="el-icon-s-data"></el-input>
+                  </el-form-item>
+                  <el-form-item label="复消结余" prop="SURPLUS_3L_FX">
+                    <el-input type="text" size="small" v-model="item.SURPLUS_3L_FX" autocomplete="off" prefix-icon="el-icon-s-data"></el-input>
+                  </el-form-item>
+
+                  <el-form-item>
+                    <el-button type="primary" size="small" @click="handlePerfAdjustment(index)">确定</el-button>
+                  </el-form-item>
+                </el-form>
+              </el-card>
+            </div>
+          </el-col>
+        </el-row>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+import network from '@/utils/network'
+
+export default {
+  name: 'bonus-perf-adjustment',
+  data() {
+    return {
+      loading: false,
+      memberCode: '',
+      show: false,
+      tableList: [
+        {
+          USER_ID: '',
+          USER_NAME: '',
+          SURPLUS_1L: '',
+          SURPLUS_1L_ZC: '',
+          SURPLUS_1L_FX: '',
+          SURPLUS_2L: '',
+          SURPLUS_2L_ZC: '',
+          SURPLUS_2L_FX: '',
+          SURPLUS_3L: '',
+          SURPLUS_3L_ZC: '',
+          SURPLUS_3L_FX: '',
+        },
+        {
+          USER_ID: '',
+          USER_NAME: '',
+          SURPLUS_1L: '',
+          SURPLUS_1L_ZC: '',
+          SURPLUS_1L_FX: '',
+          SURPLUS_2L: '',
+          SURPLUS_2L_ZC: '',
+          SURPLUS_2L_FX: '',
+          SURPLUS_3L: '',
+          SURPLUS_3L_ZC: '',
+          SURPLUS_3L_FX: '',
+        },
+        {
+          USER_ID: '',
+          USER_NAME: '',
+          SURPLUS_1L: '',
+          SURPLUS_1L_ZC: '',
+          SURPLUS_1L_FX: '',
+          SURPLUS_2L: '',
+          SURPLUS_2L_ZC: '',
+          SURPLUS_2L_FX: '',
+          SURPLUS_3L: '',
+          SURPLUS_3L_ZC: '',
+          SURPLUS_3L_FX: '',
+        }
+      ],
+    }
+  },
+  methods: {
+    // 查询安置网的下级会员和业绩
+    getData() {
+      if (!this.memberCode.length) {
+        this.$message({
+          message: '请输入会员名字',
+          type: 'info'
+        });
+        return false;
+      }
+      return network.getData(`bonus/perf-adjustment`, { memberCode : this.memberCode }).then(response => {
+        this.tableList = response.allData;
+        this.show = response.allData.length > 0;
+        this.loading = false;
+      }).catch(error => {
+        this.$message({
+          message: error,
+          type: 'error'
+        });
+
+        this.loading = false;
+      })
+    },
+    // 修改会员业绩
+    handlePerfAdjustment(formName) {
+      this.$confirm('确认修改会员业绩?', '提示', { //
+        confirmButtonText: '确认',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.loading = true;
+        return network.postData(`bonus/perf-adjustment`, this.tableList[formName]).then(response => {
+          this.$message({
+            message: response,
+            type: 'success'
+          });
+          this.loading = false;
+
+          // 刷新数据
+          this.getData();
+        }).catch(error => {
+          this.$message({
+            message: error,
+            type: 'warning'
+          });
+          this.loading = false;
+        });
+      })
+    },
+  }
+}
+</script>
+
+<style>
+  .filter-user { font-size: 14px; margin-bottom: 20px; }
+  .filter-user:after { content: ''; display: table;  clear: both; }
+</style>

+ 10 - 0
common/models/UserInfo.php

@@ -248,4 +248,14 @@ class UserInfo extends \common\components\ActiveRecord
             ],
         ];
     }
+
+        /**
+     * 查询安置网的会员
+     * @param $userId
+     * @return array|null
+     */
+    public static function getPlacementChildren($userId): ?array
+    {
+        return static::findAllAsArray('REC_UID=:REC_UID', [':REC_UID' => $userId], 'USER_ID,USER_NAME');
+    }
 }

+ 19 - 0
common/models/UserPerf.php

@@ -171,6 +171,15 @@ class UserPerf extends \common\components\ActiveRecord
             'PV_4L' => '四市场累计业绩',
             'PV_5L' => '五市场累计业绩',
             'PV_PSS' => '推荐团队累计业绩',
+            'SURPLUS_1L'    => '一市场综合结余业绩',
+            'SURPLUS_1L_ZC' => '一市场综合报单业绩',
+            'SURPLUS_1L_FX' => '一市场复消结余业绩',
+            'SURPLUS_2L'    => '二市场综合结余业绩',
+            'SURPLUS_2L_ZC' => '二市场综合报单业绩',
+            'SURPLUS_2L_FX' => '二市场复消结余业绩',
+            'SURPLUS_3L'    => '三市场综合结余业绩',
+            'SURPLUS_3L_ZC' => '三市场综合报单业绩',
+            'SURPLUS_3L_FX' => '三市场复消结余业绩',
         ];
     }
 
@@ -217,4 +226,14 @@ class UserPerf extends \common\components\ActiveRecord
 
         return $result;
     }
+
+        /**
+     * 查询会员结余业绩
+     * @param $userId
+     * @return array|null
+     */
+    public static function getPerfMarket($userId): ?array
+    {
+        return self::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $userId], 'USER_ID,SURPLUS_1L,SURPLUS_1L_ZC,SURPLUS_1L_FX,SURPLUS_2L,SURPLUS_2L_ZC,SURPLUS_2L_FX,SURPLUS_3L,SURPLUS_3L_ZC,SURPLUS_3L_FX');
+    }
 }

+ 136 - 0
common/models/forms/PerfAdjustmentForm.php

@@ -0,0 +1,136 @@
+<?php
+namespace common\models\forms;
+
+use common\components\Model;
+use common\helpers\Form;
+use common\libs\logging\operate\AdminOperate;
+use common\models\Period;
+use common\models\UserPerf;
+use yii\base\Exception;
+
+class PerfAdjustmentForm extends Model
+{
+    public $USER_ID;
+    public $USER_NAME;
+
+    public $SURPLUS_1L;
+    public $SURPLUS_1L_ZC;
+    public $SURPLUS_1L_FX;
+
+    public $SURPLUS_2L;
+    public $SURPLUS_2L_ZC;
+    public $SURPLUS_2L_FX;
+
+    public $SURPLUS_3L;
+    public $SURPLUS_3L_ZC;
+    public $SURPLUS_3L_FX;
+
+    public function init()
+    {
+        parent::init();
+        $this->adminOperateLogger = new AdminOperate([
+            'fetchClass' => UserPerf::class,
+        ]);
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['USER_ID', 'SURPLUS_1L', 'SURPLUS_1L_ZC', 'SURPLUS_1L_FX', 'SURPLUS_2L', 'SURPLUS_2L_ZC', 'SURPLUS_2L_FX', 'SURPLUS_3L', 'SURPLUS_3L_ZC', 'SURPLUS_3L_FX'], 'required'],
+        ];
+    }
+
+    /**
+     * 指定场景
+     * @return array
+     */
+    public function scenarios() {
+        $parentScenarios = parent::scenarios();
+        $customScenarios = [
+            'perfAdjustment' => ['USER_ID', 'USER_NAME', 'SURPLUS_1L', 'SURPLUS_1L_ZC', 'SURPLUS_1L_FX', 'SURPLUS_2L', 'SURPLUS_2L_ZC', 'SURPLUS_2L_FX', 'SURPLUS_3L', 'SURPLUS_3L_ZC', 'SURPLUS_3L_FX']
+        ];
+        return array_merge($parentScenarios, $customScenarios);
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'USER_ID'       => '会员ID',
+            'SURPLUS_1L'    => '一市场综合结余业绩',
+            'SURPLUS_1L_ZC' => '一市场综合报单业绩',
+            'SURPLUS_1L_FX' => '一市场复消结余业绩',
+            'SURPLUS_2L'    => '二市场综合结余业绩',
+            'SURPLUS_2L_ZC' => '二市场综合报单业绩',
+            'SURPLUS_2L_FX' => '二市场复消结余业绩',
+            'SURPLUS_3L'    => '三市场综合结余业绩',
+            'SURPLUS_3L_ZC' => '三市场综合报单业绩',
+            'SURPLUS_3L_FX' => '三市场复消结余业绩',
+        ];
+    }
+
+    /**
+     * 调整会员业绩
+     * @return bool|null
+     */
+    public function perfAdjustment(): ?bool
+    {
+        if (!$this->validate()) {
+            return false;
+        }
+
+        $transaction = \Yii::$app->db->beginTransaction();
+        try {
+            // 修改前业绩
+            $userPerf = UserPerf::find()
+                ->where('USER_ID=:USER_ID', [':USER_ID' => $this->USER_ID])
+                ->select('USER_ID,SURPLUS_1L,SURPLUS_1L_ZC,SURPLUS_1L_FX,SURPLUS_2L,SURPLUS_2L_ZC,SURPLUS_2L_FX,SURPLUS_3L,SURPLUS_3L_ZC,SURPLUS_3L_FX')
+                ->one();
+            if (!$userPerf->toArray()) {
+                throw new Exception('Member performance does not exist'); // 会员业绩不存在
+            }
+
+            $this->adminOperateLogger->beforeUpdate($userPerf);
+
+            $modernPerf = [
+                'SURPLUS_1L'    => $this->SURPLUS_1L,
+                'SURPLUS_1L_ZC' => $this->SURPLUS_1L_ZC,
+                'SURPLUS_1L_FX' => $this->SURPLUS_1L_FX,
+                'SURPLUS_2L'    => $this->SURPLUS_2L,
+                'SURPLUS_2L_ZC' => $this->SURPLUS_2L_ZC,
+                'SURPLUS_2L_FX' => $this->SURPLUS_2L_FX,
+                'SURPLUS_3L'    => $this->SURPLUS_3L,
+                'SURPLUS_3L_ZC' => $this->SURPLUS_3L_ZC,
+                'SURPLUS_3L_FX' => $this->SURPLUS_3L_FX,
+            ];
+            if (!UserPerf::updateAll($modernPerf, 'USER_ID=:USER_ID', [':USER_ID' => $this->USER_ID])) {
+                throw new Exception(Form::formatErrorsForApi($userPerf->getErrors()));
+            }
+
+            $transaction->commit();
+
+            $afterUpdate = UserPerf::find()
+                ->where('USER_ID=:USER_ID', [':USER_ID' => $this->USER_ID])
+                ->select('USER_ID,SURPLUS_1L,SURPLUS_1L_ZC,SURPLUS_1L_FX,SURPLUS_2L,SURPLUS_2L_ZC,SURPLUS_2L_FX,SURPLUS_3L,SURPLUS_3L_ZC,SURPLUS_3L_FX')
+                ->one();
+            $this->adminOperateLogger->afterUpdate($afterUpdate)->clean()->save([
+                'optType' => '调整业绩',
+                'userId' => $this->USER_ID,
+                'userName' => $this->USER_NAME,
+                'periodNum' => Period::instance()->getNowPeriodNum(),
+            ]);
+        } catch (Exception $e) {
+            $transaction->rollBack();
+            $this->addError('perfAdjustment', $e->getMessage());
+            return false;
+        }
+
+        return true;
+    }
+
+}