Просмотр исходного кода

Merge branch 'new-version' into feature/dd-1141-tuihuo

root 3 лет назад
Родитель
Сommit
ea57421073

+ 1 - 0
backendApi/config/urlManagerRules.php

@@ -260,6 +260,7 @@ return [
             'POST,GET period' => 'period',
             'POST,GET other' => 'other',
             'GET dec-level' => 'dec-level',
+            'GET,POST month-limit' => 'month-limit',
             'POST dec-level-add' => 'dec-level-add',
             'POST,GET dec-level-edit/<id>' => 'dec-level-edit',
             'GET dec-level-delete/<selected>' => 'dec-level-delete',

+ 15 - 0
backendApi/modules/v1/controllers/ConfigController.php

@@ -464,6 +464,21 @@ class ConfigController extends BaseController {
         return static::notice($data);
     }
 
+    public function actionMonthLimit() {
+        if (Yii::$app->request->isPost) {
+            $postData = Yii::$app->request->post();
+            $month = $postData['month'];
+            $ret = Config::updateAll(['VALUE' => $month, 'UPDATED_AT' => Date::nowTime()], "CONFIG_NAME=:CONFIG_NAME", [':CONFIG_NAME' => 'observePeriodLimit']);
+            if ($ret) {
+                return static::notice('更新观察期成功');
+            } else {
+                return static::notice('更新观察期失败,请重试');
+            }
+        }
+        $data = Config::find()->where("CONFIG_NAME='observePeriodLimit'")->asArray()->one();
+        return static::notice($data);
+    }
+
     /**
      *  查看报单中心级别
      * @return mixed

+ 6 - 0
backendApi/modules/v1/controllers/UserController.php

@@ -122,6 +122,8 @@ class UserController extends BaseController
             'DEC_USER_NAME' => 'DU.USER_NAME',
             'IS_DEC' => 'U.IS_DEC',
             'IS_STUDIO' => 'U.IS_STUDIO',
+            'IS_STUDIO_CODE' => 'U.IS_STUDIO_CODE',
+            'IS_STUDIO_DATE' => 'U.IS_STUDIO_DATE',
             'DEC_ROLE_NAME' => 'U.DEC_ROLE_ID',
             'OPEN_BANK_NAME' => 'U.OPEN_BANK',
             'BANK_AREA' => [
@@ -183,6 +185,8 @@ class UserController extends BaseController
             'DEC_USER_NAME' => 'DU.USER_NAME',
             'IS_DEC' => 'U.IS_DEC',
             'IS_STUDIO' => 'U.IS_STUDIO',
+            'IS_STUDIO_CODE' => 'U.IS_STUDIO_CODE',
+            'IS_STUDIO_DATE' => 'U.IS_STUDIO_DATE',
             'DEC_ROLE_NAME' => 'U.DEC_ROLE_ID',
             'OPEN_BANK_NAME' => 'U.OPEN_BANK',
             'BANK_AREA' => [
@@ -1150,6 +1154,8 @@ class UserController extends BaseController
             'openBank' => $userInfo['OPEN_BANK'],
             'bankAddress' => $userInfo['BANK_ADDRESS'],
             'bankNo' => $userInfo['BANK_NO'],
+            'studiocode' => $userInfo['IS_STUDIO_CODE'],
+            'studiodate' => $userInfo['IS_STUDIO_DATE'],
         ];
 
         return static::notice($data);

+ 1 - 1
backendApi/modules/v1/models/User.php

@@ -26,7 +26,7 @@ class User extends Admin implements IdentityInterface
 //        if($userId){
 //            return static::findOne(['ID' => $userId]);
 //        }
-//        return null;
+//        return null ;
     }
 
     public function fields()

+ 8 - 0
backendApi/modules/v1/models/lists/user/IndexList.php

@@ -296,6 +296,14 @@ class IndexList extends \common\libs\dataList\DataList implements DataListInterf
                         ];
                     },
                 ],
+                'IS_STUDIO_CODE' => [
+                    'header' => '工作室编号',
+                    'headerOther' => ['width' => '120'],
+                ],
+                'IS_STUDIO_DATE' => [
+                    'header' => '工作室日期',
+                    'headerOther' => ['width' => '120'],
+                ],
                 'IS_ATLAS' => [
                     'header' => '是否显示图谱',
                     'value' => function($row) {

+ 2 - 2
backendEle/src/utils/config_development_example.js

@@ -1,5 +1,5 @@
 const APP_NAME = '奖金结算系统'
-const SERVER_API_DOMAIN = '16.163.228.151:8012'
+const SERVER_API_DOMAIN = '127.0.0.1:3030'
 const SERVER_API_HTTP_TYPE = 'http://'
 const SERVER_API_PORT = ''  // ':8102'
 const SERVER_API_VERSION = 'v1'
@@ -11,7 +11,7 @@ const ACCESS_TOKEN_PREFIX = 'Bearer '
 const CDN_BASE_URL = 'http://16.163.228.151:8016'
 const CDN_IMG_URL = `${CDN_BASE_URL}/cdn/`
 const PRICE_IS_ROUND = true
-const FRONTEND_SERVER = 'http://16.163.228.151:8012'
+const FRONTEND_SERVER = 'http://127.0.0.1:8086'
 const REGION_URL = `${CDN_BASE_URL}/cdn/jsdata/ar_region_data.js?ver=0.1`
 
 export {

+ 42 - 1
backendEle/src/views/config/dec-level.vue

@@ -61,6 +61,20 @@
         </el-dropdown>
         <el-button type="primary" size="small" @click="onAdd" v-if="false">添加级别</el-button>
       </div>
+
+      <el-form ref="form" :model="form" label-width="150px">
+        <el-form-item :label="form.monthLimitTITLE">
+          <el-input  v-model="form.monthLimitVALUE" placeholder="请输入内容">
+          </el-input>
+        <div class="white-box-footer" style="line-height: 1.2;color: #999;">
+          <p>注:</p>
+          <p>(1) 请输入正整数数字;</p>
+          <p>(2) 输入0代表无观察期,即全站升级单为全额升级;</p>
+        </div>
+        <div class="white-box-footer">
+          <el-button type="primary" @click="onSubmit" :loading="submitButtonStat">更新观察期</el-button>
+        </div></el-form-item>
+      </el-form>
     </div>
 
   </div>
@@ -81,9 +95,18 @@ export default {
       this.tableData = response.list
       this.loading = false
     })
+    network.getData('config/month-limit').then(response => {
+      this.form.monthLimitTITLE = response.TITLE
+      this.form.monthLimitVALUE = response.VALUE
+    })
   },
   data () {
     return {
+      submitButtonStat: false,
+      form:{
+        monthLimitTITLE:'',
+        monthLimitVALUE:''
+      },
       tableData: null,
       loading: true,
       tool: tool,
@@ -91,6 +114,22 @@ export default {
     }
   },
   methods: {
+    onSubmit() {
+        this.submitButtonStat = true
+        network.postData('config/month-limit', {
+          month: this.form.monthLimitVALUE,
+        }).then(response => {
+          this.$message({
+            message: response,
+            type: 'success'
+          })
+          this.submitButtonStat = false
+        
+        }).catch(response => {
+          this.submitButtonStat = false
+  
+        })
+      },
     editHandle (row) {
       this.$router.push({path: `/config/dec-level-edit/${row.ID}`})
     },
@@ -139,5 +178,7 @@ export default {
 </script>
 
 <style scoped>
-
+/deep/ .el-form-item__label {
+  text-align: left !important;
+}
 </style>

+ 14 - 4
backendEle/src/views/user/index.vue

@@ -232,7 +232,14 @@
         </el-form-item>
         <el-form-item label="银行帐号">
           <el-input v-model="formModifyProfile.bankNo"></el-input>
-        </el-form-item>
+        </el-form-item>
+        <el-form-item label="工作室编号">
+          <el-input v-model="formModifyProfile.studiocode" maxlength='5'></el-input>
+        </el-form-item>
+        <el-form-item label="工作室日期">
+        <el-date-picker v-model="formModifyProfile.studiodate" type="date" value-format="yyyy-MM-dd" placeholder="选择日期"></el-date-picker>
+        </el-form-item>
+
         <el-form-item>
           <el-button type="primary" @click="handleModifyProfileSubmit" :loading="submitProfileButtonStat">提交</el-button>
         </el-form-item>
@@ -342,7 +349,9 @@
             mobile: '',
             openBank: '',
             bankAddress: '',
-            bankNo: '',
+            bankNo: '',
+            studiocode:'',
+            studiodate:'',
         },
         passwordType: [
             {
@@ -391,7 +400,7 @@
       },
       getData(page, pageSize, isLoading = true) {
         network.getPageData(this, 'user/index', page, pageSize, this.filterModel, response => {
-          console.log(response.filterTypes);
+          console.log(response);
           this.filterTypes = response.filterTypes
         }, isLoading)
       },
@@ -731,7 +740,8 @@
       handleModifyProfile(row){
           this.dialogModifyProfileVisible = true
           let vueObj = this
-          network.getData('user/profile-get', {id: row.USER_ID}).then(response => {
+          network.getData('user/profile-get', {id: row.USER_ID}).then(response => {
+             // console.log('user/profile-get',response.userInfo);
               vueObj.formModifyProfile = response.userInfo
               vueObj.allOpenBank = response.allOpenBank
               vueObj.allNation = response.allNation

+ 4 - 2
common/helpers/bonus/BonusCalc.php

@@ -3296,9 +3296,11 @@ class BonusCalc extends BaseObject {
                 $realBonusBs = $blueStartAmount; // 蓝星奖直接取数据库中算好的值PRODUCT_POINT
                 $bonusReal += $realBonusGx + $realBonusBs + $realBonusGl;
                 $exchangePoints = isset($userBS['PRODUCT_POINT']) && !empty($userBS['PRODUCT_POINT']) ? $userBS['PRODUCT_POINT'] : 0; // 兑换积分
-
-                $bonus['BONUS_TOTAL'] = $bonus['BONUS_TOTAL'] + $buleStartOriBonus; // 管理奖在存储过程计算,这里单独加上管理奖(即蓝星奖)
                 unset($monthSumData, $bonusGxSum, $bonusGlSum);
+            } else {
+                // 蓝星奖原奖金在扣管理费的时候被加入到了BONUS_TOTAL,需要再减去原奖金
+                $oriBonusBs = isset($bonus['ORI_BONUS_BS']) && $bonus['ORI_BONUS_BS'] > 0 ? $bonus['ORI_BONUS_BS'] : 0;
+                $bonus['BONUS_TOTAL'] = $bonus['BONUS_TOTAL'] - $oriBonusBs;
             }
         }
         // if( $this->_isCalcMonth ) {

+ 5 - 7
common/helpers/bonus/PreparePerfCalc.php

@@ -807,11 +807,6 @@ class PreparePerfCalc {
         if (!$this->_isCalcMonth) {
             return true;
         }
-        file_put_contents('ccctxt.txt',var_export([
-            'offset' => $offset,
-            'CALC_MONTH' => $this->_calcYearMonth,
-            'PERIOD_NUM' => $this->_periodNum
-        ],true), FILE_APPEND);
         // AR_PERF_ORDER_PREPARE\AR_PERF_PERIOD_PREPARE\AR_PERIOD_PREPARE\AR_PERF_MONTH_PREPARE
         // AR_PERIOD_PREPARE 表只需要是结算月的数据
         // AR_PERF_PERIOD_PREPARE 表特殊,需要增加一个字段,是否存在于前三期中  已被第一次算月业绩使用过了
@@ -955,14 +950,14 @@ class PreparePerfCalc {
         echo sprintf("时间:[%s]预计月业绩,结算月新添加的用户,当前offset为:【%s】" . PHP_EOL, date('Y-m-d H:i:s', time()) , $offset);
         // 从缓存列表里面从底层往上倒序获取会员      IS_HAS_USER 0 代表是此结算周期新增的业绩 
         $allData = PerfPeriodPrepare::findUseDbCalc()
-        ->select('USER_ID, SUM(FX_AMOUNT_CASH) AS FX_AMOUNT_CASH_SUM,SUM(PV_PCS) AS PV_PCS_SUM,
+        ->select('IS_HAS_USER,USER_ID, SUM(FX_AMOUNT_CASH) AS FX_AMOUNT_CASH_SUM,SUM(PV_PCS) AS PV_PCS_SUM,
         SUM(PV_PCS_FX) AS PV_PCS_FX_SUM,SUM(PV_PSS) AS PV_PSS_SUM,
         SUM(PV_1L) AS PV_1L_SUM,SUM(PV_2L) AS PV_2L_SUM,
         SUM(PV_3L) AS PV_3L_SUM,SUM(PV_4L) AS PV_4L_SUM,
         SUM(PV_5L) AS PV_5L_SUM,SUM(PV_1L_ZC) AS PV_1L_ZC_SUM,
         SUM(PV_2L_ZC) AS PV_2L_ZC_SUM,SUM(PV_3L_ZC) AS PV_3L_ZC_SUM,
         SUM(PV_4L_ZC) AS PV_4L_ZC_SUM,SUM(PV_5L_ZC) AS PV_5L_ZC_SUM')
-        ->where('CALC_MONTH=:CALC_MONTH AND IS_HAS_USER=0', [':CALC_MONTH' => $this->_calcYearMonth])
+        ->where('CALC_MONTH=:CALC_MONTH', [':CALC_MONTH' => $this->_calcYearMonth])
         ->groupBy('USER_ID')
         ->orderBy('USER_ID DESC')
         ->offset($offset)
@@ -972,6 +967,9 @@ class PreparePerfCalc {
         if ($allData) {
             // 月度业绩表
             foreach ($allData as $everyData) {
+                if ($everyData['IS_HAS_USER'] != 0) {
+                    continue;
+                }
                 $userId = $everyData['USER_ID'];
                 //往期业绩
                 $userLastPerf = PrepareCalcCache::userPerf($userId, $this->_periodNum);

+ 49 - 0
common/helpers/user/Info.php

@@ -110,6 +110,26 @@ class Info {
         return $data;
     }
 
+    /**
+     * 获取会员信息,通过用户编号
+     * @param $userId
+     * @return array|\yii\db\ActiveRecord|null
+     * @throws Exception
+     */
+    public static function baseInfoByUserName($userName) {
+        $data = User::find()->where('USER_NAME=:USER_NAME', [':USER_NAME' => $userName])->asArray()->one();
+        if (!$data) throw new Exception('会员不存在:'.$userName);
+        $userId  = $data['ID'];
+        $infoData = UserInfo::find()->where('USER_ID=:USER_ID', [':USER_ID' => $userId])->select('ZC_PV,CON_UID,REC_UID,CON_NUM,REC_NUM,NETWORK_DEEP,RELATION_DEEP,SYSTEM_ID,REG_TYPE,REG_NAME,CREDIT_CODE,PREMISES,LEGAL_PERSON,CLOSE_LOGIN,IS_BIND_MAIN,HIGHEST_EMP_LV,HIGHEST_EMP_LV_PERIOD,SHOULD_REG_TYPE,IS_SYSTEM_LEADER,ALLOW_TRANSFER,TRANSFER_PROP,IS_GROUP_LEADER,GROUP_LEADER_AT,SHOW_EMP_LV')->asArray()->one();
+        if ($infoData) {
+            $data = array_merge($data, $infoData);
+        }
+        if (!$data['DEC_LV']) $data['DEC_LV'] = DeclarationLevel::getDefaultLevelId();
+        if (!$data['LAST_DEC_LV']) $data['LAST_DEC_LV'] = DeclarationLevel::getDefaultLevelId();
+        if (!$data['EMP_LV']) $data['EMP_LV'] = EmployLevel::getDefaultLevelId();
+        return $data;
+    }
+
     /**
      * 基本信息
      * @param $userId
@@ -139,6 +159,35 @@ class Info {
         }
     }
 
+    public static function baseInfoZhByUserName($userName) {
+        $baseInfo = self::baseInfoByUserName($userName);
+        // 状态处理
+        $baseInfo['STATUS_NAME'] = \Yii::$app->params['userStatus'][$baseInfo['STATUS']]['label'];
+        //登录状态
+        $baseInfo['LOGIN_STATUS_NAME'] = $baseInfo['ALLOW_LOGIN'] == 0 ? '禁止登录' : '允许登录';
+        // 子公司
+        $baseInfo['SUB_COM_NAME'] = '';
+        $baseInfo['PROVINCE_NAME'] = $baseInfo['PROVINCE'] ? Region::getCnName($baseInfo['PROVINCE']) : '';
+        $baseInfo['CITY_NAME'] = $baseInfo['CITY'] ? Region::getCnName($baseInfo['CITY']) : '';
+        $baseInfo['COUNTY_NAME'] = $baseInfo['COUNTY'] ? Region::getCnName($baseInfo['COUNTY']) : '';
+        $baseInfo['BANK_PROVINCE_NAME'] = $baseInfo['BANK_PROVINCE'] ? Region::getCnName($baseInfo['BANK_PROVINCE']) : '';
+        $baseInfo['BANK_CITY_NAME'] = $baseInfo['BANK_CITY'] ? Region::getCnName($baseInfo['BANK_CITY']) : '';
+        $baseInfo['BANK_COUNTY_NAME'] = $baseInfo['BANK_COUNTY'] ? Region::getCnName($baseInfo['BANK_COUNTY']) : '';
+        $baseInfo['OPEN_BANK_NAME'] = $baseInfo['OPEN_BANK'] ? OpenBank::getCnName($baseInfo['OPEN_BANK']) : '';
+        // 获取会员体系
+        $baseInfo['SYSTEM_NAME'] = '';
+        // 获取会员级别名称
+        $baseInfo['DEC_LV_NAME'] = Cache::getDecLevelConfig()[$baseInfo['DEC_LV']]['LEVEL_NAME'];
+        $baseInfo['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$baseInfo['LAST_DEC_LV']]['LEVEL_NAME'];
+        $baseInfo['EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$baseInfo['EMP_LV']]['LEVEL_NAME'];
+        $baseInfo['HIGHEST_EMP_LV_NAME'] = '';
+        // 获取会员报单级别
+        $baseInfo['DEC_ROLE_NAME'] = '无';
+        //民族
+        $baseInfo['NATION_NAME'] = \Yii::$app->params['nation'][$baseInfo['NATION']]['name']??'';
+        return $baseInfo;
+    }
+
     /**
      * 基本信息含中文地区和中文子公司
      * @param $userId

+ 0 - 0
common/models/CalcBonusBsDetail.php


+ 63 - 1
common/models/DecLevelLog.php

@@ -2,6 +2,9 @@
 
 namespace common\models;
 
+use common\helpers\Date;
+use common\helpers\Form;
+use Exception;
 use Yii;
 
 /**
@@ -34,7 +37,7 @@ class DecLevelLog extends \common\components\ActiveRecord
     public function rules()
     {
         return [
-            [['USER_ID', 'FROM_ID', 'TO_ID', 'PERIOD_NUM', 'CALC_MONTH', 'REMARK', 'CREATED_AT'], 'required'],
+            [['USER_ID', 'FROM_ID', 'TO_ID', 'PERIOD_NUM', 'CALC_MONTH', 'CREATED_AT'], 'required'],
             [['PERIOD_NUM', 'CALC_MONTH', 'STATUS', 'CREATED_AT'], 'integer'],
             [['ID', 'USER_ID', 'FROM_ID', 'TO_ID', 'ADMIN_ID'], 'string', 'max' => 32],
             [['REMARK'], 'string', 'max' => 4000],
@@ -60,4 +63,63 @@ class DecLevelLog extends \common\components\ActiveRecord
             'CREATED_AT' => '创建时间',
         ];
     }
+
+    // 会员端升级报单操作,添加记录
+    public function frontendChange($data) {
+        $db = \Yii::$app->db;
+        $transaction = $db->beginTransaction();
+        try {
+            // 恢复所传期数的和这个会员相关的其他调整
+            $period = Period::instance();
+            $periodNum = $nowPeriodNum = $period->getNowPeriodNum();
+            DecLevelLog::updateAll(
+                [
+                    'STATUS' => 0
+                ], 
+                    'USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM', 
+                [
+                    ':USER_ID' => $data['userId'], ':PERIOD_NUM' => $periodNum
+                ]
+            );
+            // 新增数据
+            $model = new DecLevelLog();
+            $model->USER_ID = $data['userId'];
+            $model->FROM_ID = $data['fromId'];
+            $model->TO_ID = $data['levelId'];
+            $model->PERIOD_NUM = 0;
+            $model->CALC_MONTH = 0;
+            $model->REMARK = isset($data['remark']) ? $data['remark'] : '';
+            $model->STATUS = 1;
+            $model->ADMIN_ID = $data['actionId'];
+            $model->CREATED_AT = Date::nowTime();
+            $model->DEC_TYPE = 2;
+            if (!$model->save()) {
+                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
+            }
+            //修改会员级别,如果是上期,则一起变化,如果不是,则只改变实时级别
+            $nowTime = Date::nowTime();
+            User::updateAll(
+                [
+                    'LAST_DEC_LV' => $data['levelId'], 
+                    'DEC_LV' => $data['levelId'], 
+                    'DEC_LV_UPDATED_AT'=>$nowTime, 
+                    'DEC_LV_UPDATED_PERIOD'=>$nowPeriodNum, 
+                    'LAST_DEC_LV_UPDATED_AT'=>$nowTime, 
+                    'LAST_DEC_LV_UPDATED_PERIOD'=>$nowPeriodNum, 
+                    'ZG_UPGRADE_PV'=>$data['lvPv']
+                ], 
+                'ID=:ID', 
+                [
+                    ':ID' => $data['userId']
+                ]
+            );
+
+            $transaction->commit();
+        } catch (Exception $e) {
+            $transaction->rollBack();
+            $this->addError('adminChange', $e->getMessage());
+            return null;
+        }
+        return $model;
+    }
 }

+ 41 - 0
common/models/DeclarationLevel.php

@@ -102,6 +102,47 @@ class DeclarationLevel extends \common\components\ActiveRecord
         return $data;
     }
 
+    // 获取最大的业绩信息
+    public static function getMaxDecPref() {
+        
+        $data = static::find()->where('1=1')->orderBy('PERF DESC')->indexBy('ID')->asArray()->one();
+
+        return $data;
+    }
+
+    // 获取下一级业绩数据
+    public static function getNextDecPref($perf) {
+        $data = static::find()
+        ->where('PERF>:PERF', 
+            [
+                'PERF'=>$perf, 
+                
+            ]
+        )
+        ->orderBy('PERF ASC')
+        ->indexBy('ID')
+        ->asArray()
+        ->one();
+
+        return $data;
+    }
+
+    public static function getNextAll($perf){
+        $data = static::find()
+        ->where('PERF>:PERF', 
+            [
+                'PERF'=>$perf, 
+                
+            ]
+        )
+        ->indexBy('ID')
+        ->orderBy('SORT ASC')
+        ->asArray()
+        ->all();
+
+        return $data;
+    }
+
     /**
      * @return array|\yii\db\ActiveRecord[]
      */

+ 52 - 0
common/models/OriginDecPv.php

@@ -0,0 +1,52 @@
+<?php
+
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%ORIGIN_DEC_PV}}".
+ *
+ * @property string $ID
+ * @property string $USER_ID 会员ID
+ * @property int $TYPE 报单类型
+ * @property string $INSERT_USER_ID 首购会员ID
+ * @property string $DEC_AMOUNT 报单金额
+ * @property string $DEC_PV 报单PV
+ * @property int $PERIOD_NUM 报单期数
+ * @property int $STATUS 状态
+ * @property int $CREATED_AT 创建时间
+ */
+class OriginDecPv extends \common\components\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%ORIGIN_DEC_PV}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['USER_ID', 'DEC_PV', 'ACTION_TYPE'], 'required'],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'DEC_PV' => '报单PV值',
+            'ACTION_TYPE' => '操作类型默认0无操作  1为增加  2为减少',
+        ];
+    }
+}

+ 64 - 0
common/models/UpgradeType.php

@@ -0,0 +1,64 @@
+<?php
+
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%UPGRADE_TYPE}}".
+ *
+ * @property string $ID
+ * @property string $USER_ID 会员ID
+ * @property int $TYPE 报单类型
+ * @property string $INSERT_USER_ID 首购会员ID
+ * @property string $DEC_AMOUNT 报单金额
+ * @property string $DEC_PV 报单PV
+ * @property int $PERIOD_NUM 报单期数
+ * @property int $STATUS 状态
+ * @property int $CREATED_AT 创建时间
+ */
+class UpgradeType extends \common\components\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%UPGRADE_TYPE}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['OBSERVE_NAME', 'SORTS', 'IS_STATUS', 'NATION_ID','OBSERVE_TYPE','CREATE_AT'], 'required'],
+            [['OBSERVE_TYPE', 'NATION_ID', 'IS_STATUS', 'CREATED_AT'], 'integer'],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'OBSERVE_NAME' => '升级方式名称',
+            'SORTS' => '排序',
+            'IS_STATUS' => '状态0为默认启用  1为禁用 ',
+            'NATION_ID' => '国家id',
+            'OBSERVE_TYPE' => '升级类型 1为补差额升级类型  2为全额升级类型',
+            'CREATE_AT' => '创建时间'
+        ];
+    }
+
+    // 根据类型获取升级方式
+    public static function getOneByType($type) {
+        $result = UpgradeType::findOneAsArray('OBSERVE_TYPE=:OBSERVE_TYPE  AND IS_STATUS=0', [':OBSERVE_TYPE'=>$type]);
+        
+        return $result;
+    }
+}

+ 67 - 2
common/models/User.php

@@ -92,6 +92,8 @@ use common\libs\logging\operate\valueType\Config as ValueTypeConfig;
  * @property int $IS_FIRST_OPEN 首次开通
  * @property int $IS_MODIFY_PASSWORD 是否修改密码
  * @property int $IS_STUDIO 是否是工作室
+ * @property int $IS_STUDIO_CODE 工作室编号
+ * @property int $IS_STUDIO_DATE 工作室时间
  */
 class User extends \common\components\ActiveRecord
 {
@@ -212,6 +214,8 @@ class User extends \common\components\ActiveRecord
             'IS_FIRST_OPEN' => '首次开通',
             'IS_MODIFY_PASSWORD' => '是否修改密码',
             'IS_STUDIO' => '是否是工作室',
+            'IS_STUDIO_CODE' => '工作室编号',
+            'IS_STUDIO_DATE' => '工作室日期',
         ];
     }
 
@@ -296,7 +300,7 @@ class User extends \common\components\ActiveRecord
             'CITY' => $userInfo['CITY'],
             'COUNTY' => $userInfo['COUNTY'],
             'BANK_NO' => $userInfo['BANK_NO'],
-//            'BANK_NO' => Tool::hideBankNo($userInfo['BANK_NO']),
+//            'BANK_NO' => Tool::hideBankNo($userInfo['BANK_NO']) ,
         ];
     }
 
@@ -387,6 +391,68 @@ class User extends \common\components\ActiveRecord
         }
     }
 
+    
+    /**
+     *  判断用户是否是观察期
+     *  观望期:自加入算起2个月
+     *  例子:2022年5月14日加入, 观望期至2022年7月31日。
+     *  true为是观察期用户  false为不是观察期用户
+     * @param $addAt 用户的加入时间
+     * @param $month 观察期月份限制 系统初始化为2个月
+     */
+    public static function checkIsObserve($addAt, $month) {
+        if (empty($month)) {
+            // 如果0 代表全站全额升级
+            return false;
+        }
+        $appendMonth = date("Y-m", strtotime("first day of +$month month", $addAt)); // 指定月份
+        $lastDay = date("t", strtotime($appendMonth));  // 获取指定月的最后一天
+        $eTime = strtotime($appendMonth.'-'.$lastDay);
+
+        return time() < $eTime ? true : false;
+    }
+
+    // 获取用户报单PV总和
+    public static function sumDevPvByUserId($userId) {
+        $decOrderPv = DecOrder::find()
+        ->select('SUM(DEC_PV) AS PV_SUM')
+        ->where('TO_USER_ID=:TO_USER_ID AND IS_DEL=0', 
+            [
+                'TO_USER_ID'=>$userId, 
+                
+            ]
+        )
+        ->asArray()
+        ->one();
+        $decOrderPv = isset($decOrderPv['PV_SUM']) ? $decOrderPv['PV_SUM'] : 0;
+        $orderDecPv = OrderDec::find()
+        ->select('SUM(PAY_PV) AS PV_SUM')
+        ->where('USER_ID=:USER_ID AND IS_DELETE=0', 
+            [
+                'USER_ID'=>$userId, 
+                
+            ]
+        )
+        ->asArray()
+        ->one();
+        $orderDecPv = isset($orderDecPv['PV_SUM']) ? $orderDecPv['PV_SUM'] : 0;
+        // 还得加上用户在老系统中的所有报单PV之和
+        $originPv = OriginDecPv::find()
+        ->select('SUM(DEC_PV) AS PV_SUM')
+        ->where('USER_ID=:USER_ID', 
+            [
+                'USER_ID'=>$userId, 
+                
+            ]
+        )
+        ->asArray()
+        ->one();
+        $originPv = isset($originPv['PV_SUM']) ? $originPv['PV_SUM'] : 0;
+        $total = $orderDecPv + $decOrderPv + $originPv;
+
+        return $total;
+    }
+
     /**
      * 操作日志记录条件
      * @return array
@@ -494,5 +560,4 @@ class User extends \common\components\ActiveRecord
             'SEX' => '性别',
         ];
     }
-
 }

+ 0 - 2
common/models/forms/DecLevelLogForm.php

@@ -171,6 +171,4 @@ class DecLevelLogForm extends Model
         ]);
         return $model;
     }
-
-
 }

+ 438 - 0
common/models/forms/DeclarationUpgradeForm.php

@@ -0,0 +1,438 @@
+<?php
+namespace common\models\forms;
+
+use common\components\Model;
+use common\helpers\Cache;
+use common\helpers\Date;
+use common\helpers\Form;
+use common\helpers\user\Cash;
+use common\helpers\user\Info;
+use common\models\Config;
+use common\models\DeclarationLevel;
+use common\models\DeclarationPackage;
+use common\models\DecLevelLog;
+use common\models\DecOrder;
+use common\models\EmployLevel;
+use common\models\Order;
+use common\models\OrderGoods;
+use common\models\Period;
+use common\models\ReceiveAddress;
+use common\models\Region;
+use common\models\ShopGoods;
+use common\models\User;
+use common\models\UserInfo;
+use common\models\UserNetwork;
+use yii\base\Exception;
+
+/**
+ * 升级管理,进行升级
+ */
+class DeclarationUpgradeForm extends Model
+{
+    public $type;
+    public $decLv;
+    public $decWay;
+    public $packageId;
+    public $goodsId;
+    public $goodsNum;
+    public $insertUserName;
+    public $consignee;
+    public $acceptMobile;
+    public $province;
+    public $city;
+    public $county;
+    public $address;
+    public $nowPerf;
+    public $nextPerf;
+    public $decUserName;
+    public $remark;
+    // 传过来的全部数据
+    public $allData;
+    private $_decId;
+    public $_insertUserId;
+    private $_decAmount;
+    private $_decPv;
+    private $_orderGoods;
+    const TYPE_ZC = 'ZC';
+    private $_userForm = null;
+    // 全部的安置网上级
+    private $_tempNetworkParentUser = [];
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['remark','type','decLv','decWay','packageId','goodsId', 'goodsNum', 'insertUserName','consignee','acceptMobile','province','city','county','address','nowPerf','nextPerf'], 'trim'],
+            [['type','decLv','decWay','insertUserName','nowPerf','province','city','county','address','acceptMobile'], 'required'],
+            [['decUserName'], 'issetDec'], // 必须是报单中心
+            [['decWay'], 'hasProduct'],// 必须选择商品
+            [['decLv'], 'alreadyMaxDec'], //判断要升级用户是否已经是最高级
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'type' => '升级类型',
+            'decLv' => '升级级别',
+            'decWay' => '报单方式',
+            'packageId' => '升级套餐',
+            'goodsId' => '商品ID',
+            'goodsNum' => '商品数量',
+            'insertUserName' => '要升级的会员编号',
+            'consignee' => '收货人',
+            'acceptMobile' => '收货人手机',
+            'province' => '收货省',
+            'city' => '收货市',
+            'county' => '收货区县',
+            'address' => '收货详细地址',
+        ];
+    }
+
+    /**
+     * 添加报单
+     * @param $allData
+     * @return bool|null
+     * @throws Exception
+     * @throws \yii\db\Exception
+     */
+    public function add($allData){
+        if(!$this->validate()){
+            return null;
+        }
+        $loginUserId = \Yii::$app->user->id;
+        // 首购单
+        if($this->type == self::TYPE_ZC){
+            //报单商品及PV判断
+            $decLevelConfig = Cache::getDecLevelConfig();
+            $decLevel = $decLevelConfig[$this->decLv];
+            $toDecLevel = $this->decLv;
+            if(!$this->decLv){
+                throw new Exception('请选择升级级别');
+            }
+            $baseInfo = Info::baseInfoZhByUserName($this->insertUserName);
+            $userId = $baseInfo['ID'];
+            $userDecPvSum = User::sumDevPvByUserId($userId); // 用户所有报单PV总和
+            if ($userDecPvSum != $this->nowPerf) {
+                throw new Exception('请联系客服人员核对升级会员业绩');
+            }
+            // 获取用户是否是观察期
+            $observe = Config::getConfigByType('observe'); // 获取观察期配置信息
+            $observeLimit = $observe['observePeriodLimit']['value']; // 月份限制
+            $isObserve = User::checkIsObserve($baseInfo['CREATED_AT'], $observeLimit); // 判断用户是否再观察期中
+            $diffPerf = $isObserve ? $this->nowPerf : 0; // 观察期内升级要加上用户累计的PV,全额则基础PV为0,全额购买
+            if ($this->decWay != 2) {
+                throw new Exception('升级方式不正确,请联系客服人员');
+            }
+            if($this->decWay==1) {
+                // 先不加套餐升级方式
+                // $decPackage = DeclarationPackage::findOneAsArray('ID=:ID', [':ID'=>$this->packageId]);
+                // $this->_decAmount = $decPackage['AMOUNT'];
+                // $this->_decPv = $decPackage['PV'];
+                // $this->_orderGoods[] = [
+                //     'GOODS_ID' => $this->packageId,
+                //     'PRICE' => $this->_decAmount,
+                //     'REAL_PRICE' => $this->_decAmount,
+                //     'PV' => $this->_decPv,
+                //     'REAL_PV' => $this->_decPv,
+                //     'BUY_NUMS' => 1,
+                //     'SKU_CODE' => $decPackage['PACKAGE_NO'],
+                //     'GOODS_TITLE' => $decPackage['PACKAGE_NAME']
+                // ];
+            } else {
+                $ids = $this->goodsId;
+                $totalAmount = 0;
+                $totalPv = 0;
+                foreach ($this->goodsNum as $k => $v) {
+                    if ($v) {
+                        $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
+                        if($goods['STORE_NUMS']>0){
+                            $totalAmount += $goods['SELL_PRICE'] * intval($v);
+                            $totalPv += $goods['PRICE_PV'] * intval($v);
+                            $this->_orderGoods[] = [
+                                'GOODS_ID' => $goods['ID'],
+                                'PRICE' => $goods['SELL_PRICE'],
+                                'REAL_PRICE' => $goods['SELL_PRICE'],
+                                'PV' => $goods['PRICE_PV'],
+                                'REAL_PV' => $goods['PRICE_PV'],
+                                'POINT' => $goods['POINT'],
+                                'BUY_NUMS' => intval($v),
+                                'SKU_CODE' => $goods['GOODS_NO'],
+                                'GOODS_TITLE' => $goods['GOODS_NAME']
+                            ];
+                        }
+                    }
+                }
+                // 这里特殊是用户原报单PV之和+用户购买的商品总PV
+                $checkPv = $totalPv + $diffPerf;
+                if($checkPv < $decLevel['PERF']) {
+                    throw new Exception('总PV不能小于所选级别PV');
+                }
+                foreach ($decLevelConfig as $key=>$val){
+                    if($checkPv>=$val['PERF']){
+                        $toDecLevel = $key;
+                    }
+                }
+                if($this->decLv!=$toDecLevel){
+                    throw new Exception('总PV不能超过已选级别下一个级别的PV值');
+                }
+                $this->_decAmount = $totalAmount;
+                $this->_decPv = $totalPv;
+            }
+            //看现金余额是否充足
+            if (Cash::getAvailableBalance($loginUserId) < $this->_decAmount){
+                throw new Exception('报单人现金不足,无法完成报单');
+            }
+            $baseInfo = Info::baseInfoZhByUserName($this->insertUserName);
+            $this->_insertUserId = $baseInfo['ID']; // 被报单人,通过insername 查找用户id
+            $insertConId = $baseInfo['CON_UID'];
+            $insertRecId = $baseInfo['REC_UID'];
+            if(!($decResult = $this->addDecOrder($insertConId,$insertRecId, $baseInfo['DEC_LV'],$isObserve,$this->remark))) {
+                throw new Exception("操作失败");
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 添加报单订单
+     * @return bool|UserInfo|null
+     * @throws \yii\db\Exception
+     */
+    public function addDecOrder($insertConId,$insertRecId,$oriDecLv,$isObserve,$remark=''){
+        $warehouse = Region::getWarehouseByCode($this->province);//仓库
+        if(!$warehouse){
+            throw new Exception('地区暂时不支持配送,具体联系客服');
+        }
+        
+        $upgradeType = $isObserve ? 1 : 2; // 1补差  2全额
+        $periodObj = Period::instance();
+        $nowPeriodNum = $periodObj->getNowPeriodNum();
+        $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
+        $ord = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 10);
+        // 加入报单信息
+        $db = \Yii::$app->db;
+        $transaction = $db->beginTransaction();
+        try {
+            $decOrderModel = new DecOrder();
+            $decOrderModel->DEC_SN = 'DS'.$ord;
+            $decOrderModel->ORDER_SN = 'OS'.$ord;
+            $decOrderModel->TYPE = $this->type;
+            $decOrderModel->USER_ID = \Yii::$app->user->id; // 报单人
+            $decOrderModel->TO_USER_ID = $this->_insertUserId; // 被报单人
+            $decOrderModel->DEC_AMOUNT = $this->_decAmount;
+            $decOrderModel->DEC_PV = $this->_decPv;
+            $decOrderModel->PERIOD_NUM = $nowPeriodNum;
+            $decOrderModel->CALC_MONTH = $nowCalcMonth;
+            $decOrderModel->P_CALC_MONTH = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
+            $decOrderModel->PAID_WALLET = 'cash';
+            $decOrderModel->CON_USER_ID = $insertConId;
+            $decOrderModel->REC_USER_ID = $insertRecId;
+            $decOrderModel->DEC_ID = $this->_decId;
+            $decOrderModel->IS_DEL = 0;
+            $decOrderModel->DETAIL_TYPE = 2;
+            $decOrderModel->CREATED_AT = Date::nowTime();
+            $decOrderModel->UPGRADE_TYPE = $upgradeType;
+            $decOrderModel->REMARK = $remark;
+            if(!$decOrderModel->save()){
+                $transaction->rollBack();
+                throw new Exception(Form::formatErrorsForApi($decOrderModel->getErrors()));
+            }
+
+            $orderModel = new Order();
+            $orderModel->SN = 'OS'.$ord;
+            $orderModel->DEC_SN = 'DS'.$ord;
+            $orderModel->ORDER_TYPE = $this->type;
+            $orderModel->USER_ID = $this->_insertUserId;
+            $orderModel->USER_NAME = $this->insertUserName; // 要升级的用户
+            $orderModel->ORDER_AMOUNT = $this->_decAmount;
+            $orderModel->PV = $this->_decPv;
+            $orderModel->PAY_AMOUNT = $this->_decAmount;
+            $orderModel->PAY_PV = $this->_decPv;
+            $orderModel->PAY_AT = Date::nowTime();
+            $orderModel->PAY_TYPE = 'cash';
+            $orderModel->PERIOD_NUM = $nowPeriodNum;
+            $orderModel->P_CALC_MONTH = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
+            $orderModel->FREIGHT = 0;
+            $orderModel->PAY_FREIGHT = 0;
+            $orderModel->CONSIGNEE = $this->consignee;
+            $orderModel->MOBILE = $this->acceptMobile;
+            $orderModel->PROVINCE = $this->province;
+            $orderModel->CITY = $this->city;
+            $orderModel->COUNTY = intval($this->county) ?? 0;
+            $orderModel->ADDRESS = $this->address;
+            $orderModel->WAREHOUSE = $warehouse;
+            $orderModel->STATUS = 1;
+            $orderModel->CREATED_AT = Date::nowTime();
+            $orderModel->CREATE_USER = Info::getUserNameByUserId(\Yii::$app->user->id);
+            if(!$orderModel->save()){
+                $transaction->rollBack();
+                throw new Exception(Form::formatErrorsForApi($orderModel->getErrors()));
+            }
+            // 加入商品到订单商品表
+            foreach($this->_orderGoods as $key=>$value){
+                $this->_orderGoods[$key]['ORDER_SN'] = $orderModel->SN;
+                $this->_orderGoods[$key]['P_CALC_MONTH'] = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
+            }
+            OrderGoods::batchInsert($this->_orderGoods);
+            //写入收货地址信息
+            $addressModel = new ReceiveAddress();
+            $addressModel->USER_ID = $this->_insertUserId;
+            $addressModel->USER_NAME = $this->insertUserName;
+            $addressModel->CONSIGNEE = $this->consignee;
+            $addressModel->MOBILE = $this->acceptMobile;
+            $addressModel->PROVINCE = $this->province;
+            $addressModel->CITY = $this->city;
+            $addressModel->COUNTY = intval($this->county) ?? 0;
+            $addressModel->ADDRESS = $this->address;
+            $addressModel->IS_DEFAULT = 0;
+            if(!$addressModel->save()){
+                $transaction->rollBack();
+                throw new Exception(Form::formatErrorsForApi($addressModel->getErrors()));
+            }
+            // 扣报单人现金钱包
+            Cash::changeUserCash(\Yii::$app->user->id, 'CASH', -abs($this->_decAmount), ['REMARK' =>'为'.$this->insertUserName.'升级报单']);
+            // 为被升级人进行升级操作
+            $decLevelLog = new DecLevelLog();
+            $decLog = [
+                'userId' => $this->_insertUserId,//会员ID
+                'fromId' => $oriDecLv, // 变动前的级别
+                'levelId' => $this->decLv,// 变动后的级别
+                'actionId' => \Yii::$app->user->id,
+                'remark' => $this->remark,
+                'lvPv' => $this->_decPv
+            ];
+            $modifyDecLv = $decLevelLog->frontendChange($decLog);
+            if (empty($modifyDecLv)) {
+                $transaction->rollBack();
+                throw new Exception("为会员升级失败");
+            }
+            $transaction->commit();
+        } catch(Exception $e) {
+            $transaction->rollBack();
+            throw new Exception($e->getMessage());
+            
+            return false;
+        }
+
+        return $modifyDecLv;
+    }
+
+    /**
+     * 判断报单中心是否存在
+     * @param $attribute
+     */
+    public function issetDec($attribute){
+        $decUser = User::find()
+        ->select('ID')
+        ->where('IS_DEC=1 AND USER_NAME=:USER_NAME', [':USER_NAME' => $this->decUserName])
+        ->asArray()
+        ->one();
+        if (!$decUser) {
+            $this->addError($attribute, '报单中心不存在');
+            return false;
+        } else {
+            // 判断报单中心是否在新加入会员的安置网上级中
+            $this->loopFindParentToNetwork($this->insertUserName);
+            //反转数组,in_array搜索错误
+            //in_array($this->decUserName, $this->_tempNetworkParentUser[$this->insertUserName]);
+            $flipParent = array_flip(array_filter($this->_tempNetworkParentUser[$this->insertUserName]));
+            if (!isset($flipParent[$this->decUserName])) {
+                $this->addError($attribute, '为' . $this->insertUserName . '升级报单,报单中心' . $this->decUserName . '不在' . $this->insertUserName . '的安置网上级中');
+                return ;
+            }
+            $this->_decId = $decUser['ID'];
+        }
+    }
+
+
+    // 判断是否已选择商品或套餐
+    public function hasProduct($attribute) {
+        if ($this->decWay==1 && empty($this->packageId)) {
+            $this->addError($attribute, '购买套餐升级,请选择套餐');
+            return false;
+        }
+        if ($this->decWay!=1 && empty($this->goodsId)) {
+            $this->addError($attribute, '购买商品升级,请选择商品');
+            return false;
+        }
+
+        return true;
+    }
+
+    // 判断要升级的会员,是否已是最高级别
+    public function alreadyMaxDec($attribute) {
+        $baseInfo = Info::baseInfoZhByUserName($this->insertUserName);
+        $userDecId = $baseInfo['DEC_LV'];// 用户当前的级别
+        $maxPerfInfo = DeclarationLevel::getMaxDecPref(); 
+        $maxDecId = $maxPerfInfo['ID']; // 级别配置中最高级别ID
+        if ($maxDecId == $userDecId) {
+            $this->addError($attribute, '已是最高级别,无需升级');
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * 寻找被升级人的上级
+     * @param null $conUserName
+     * @return bool
+     */
+    private function loopFindParentToNetwork($conUserName = null) {
+        if($conUserName == null ){
+            $conUserName = $this->insertUserName;
+        }
+        $baseUser = Info::getBaseUserByUserName($conUserName);
+        $userNetworkInfo = UserNetwork::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $baseUser['ID']]);
+        unset($baseUser);
+        $allParentUserIdsArr = explode(',', $userNetworkInfo['PARENT_UIDS']);
+        unset($userNetworkInfo);
+        $allParentUserIds = array_reverse($allParentUserIdsArr);
+        unset($allParentUserIdsArr);
+        if($allParentUserIds){
+            foreach($allParentUserIds as $parentUserId) {
+                $parentBaseUser = Info::getBaseUserById($parentUserId);
+                $this->_tempNetworkParentUser[$this->insertUserName][] = $parentBaseUser['USER_NAME'] ;
+
+                unset($parentUserId, $parentBaseUser);
+            }
+        }
+        unset($allParentUserIds);
+        
+        return true;
+    }
+
+
+    // /**
+    //  * 删单
+    //  * @return bool
+    //  * @throws \yii\db\Exception
+    //  */
+    // public function delete(){
+    //     if(!$this->validate()){
+    //         return false;
+    //     }
+    //     $transaction = \Yii::$app->db->beginTransaction();
+    //     try {
+    //         $oneOrder = $this->_oneOrder;
+    //         // 首购单要删除会员
+    //         if($this->type == self::TYPE_ZC){
+    //             UserInfo::deleteUser($oneOrder['TO_USER_ID']);
+    //         }
+    //         // 如果是复销单的话,还需要考虑给会员的复销池减去金额
+    //         elseif($this->type == self::TYPE_FX){
+    //             Reconsume::changePoolPV($oneOrder['TO_USER_ID'], -abs($oneOrder['DEC_PV']), ['REMARK'=>'删单扣除', 'DEAL_TYPE'=>Reconsume::TYPE_AUDIT_PV]);
+    //         }
+    //         $transaction->commit();
+    //     } catch (Exception $e) {
+    //         $transaction->rollBack();
+    //         $this->addError('delete', $e->getMessage());
+    //         return false;
+    //     }
+    //     return true;
+    // }
+
+}

+ 9 - 1
common/models/forms/UserBasicForm.php

@@ -24,6 +24,8 @@ class UserBasicForm extends Model {
     public $openBank;
     public $bankAddress;
     public $bankNo;
+    public $studiocode;
+    public $studiodate;
 
     public $status;
 
@@ -44,6 +46,7 @@ class UserBasicForm extends Model {
             [['idCard', 'allData'], 'required', 'on'=>['addWithUserName']],
             [['nation','realName', 'mobile', 'idCard', 'openBank', 'bankAddress', 'bankNo'], 'required', 'on'=>'modifyProfile'],
             [['mobile'], 'mobile'],
+            [['studiocode'],'string','max'=>'5']
         ];
     }
 
@@ -55,7 +58,7 @@ class UserBasicForm extends Model {
         $parentScenarios = parent::scenarios();
         $customScenarios = [
             'modifyPassword' => ['userId', 'password', 'passwordType'],
-            'modifyProfile' => ['userId','nation','realName','idCard','mobile','openBank','bankAddress','bankNo'],
+            'modifyProfile' => ['userId','nation','realName','idCard','mobile','openBank','bankAddress','bankNo','studiocode','studiodate'],
             'modifyStatus' => ['userId','status'],
             'isModifyPasswordStatus' => ['userId','status'],
         ];
@@ -75,6 +78,7 @@ class UserBasicForm extends Model {
             'bankAddress' => '开户支行',
             'bankNo' => '银行账号',
             'status' => '状态',
+            'studiocode'=>'工作室编号'
         ];
     }
 
@@ -136,6 +140,8 @@ class UserBasicForm extends Model {
             $userModel->OPEN_BANK = $this->openBank;
             $userModel->BANK_NO = $this->bankNo;
             $userModel->BANK_ADDRESS = $this->bankAddress;
+            $userModel->IS_STUDIO_CODE = $this->studiocode;
+            $userModel->IS_STUDIO_DATE = $this->studiodate;
             if( !$userModel->save(false) ) {
                 throw new Exception($userModel->getErrors());
             }
@@ -150,6 +156,8 @@ class UserBasicForm extends Model {
                 'idCard' => $this->idCard,
                 'openBank' => $this->openBank,
                 'bankNo' => $this->bankNo,
+                'studiocode' => $this->studiocode,
+                'studiodate' => $this->studiodate,
                 'bankAddress' => $this->bankAddress,
             ]);
         }catch (Exception $e) {

+ 2 - 1
frontendApi/config/menu.php

@@ -29,7 +29,7 @@ return [
         'child'=>[
             ['name'=>'商品列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'index', 'routePath'=>'shop/index', 'show'=>1,],
             ['name'=>'复消商品', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'reconsume', 'routePath'=>'shop/reconsume', 'show'=>1,'allow'=>'studio'],
-            ['name'=>'报单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'dec-order-list', 'routePath'=>'shop/dec-order-list', 'show'=>1,],
+            ['name'=>'报单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'dec-order-list', 'routePath'=>'shop/dec-order-list', 'show'=>1,'allow'=>'declarer',],
             ['name'=>'订单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-list', 'routePath'=>'shop/order-list', 'show'=>1,],
         ]
     ],
@@ -48,6 +48,7 @@ return [
 //            ['name'=>'点位绑定列表', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'bind', 'routePath'=>'user/bind', 'show'=>1,],
 //            ['name'=>'点位绑定编辑', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'bind-edit', 'routePath'=>'user/bind-edit', 'show'=>0,],
             ['name'=>'重置密码', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'password', 'routePath'=>'user/password', 'show'=>1],
+            ['name'=>'升级管理', 'class'=>'', 'icon'=>'', 'controller'=>'upgrade', 'action'=>'dec', 'routePath'=>'user/upgrade', 'show'=>1,'allow'=>'declarer',],
             ['name'=>'报单管理', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'dec', 'routePath'=>'user/dec', 'show'=>1,'allow'=>'declarer',],
         ]
     ],

+ 2 - 0
frontendApi/config/urlManagerRules.php

@@ -89,6 +89,8 @@ return [
             'GET bind' => 'bind',
             'GET,POST bind-edit/<id>' => 'bind-edit',
             'GET,POST dec' => 'dec',
+            'GET,POST upgrade' => 'upgrade',
+            'POST upgrade-info' => 'upgrade-info',
             'GET dec-package' => 'dec-package',
             'GET full-info' => 'full-info',
             'GET user-base-info' => 'user-base-info',

+ 113 - 1
frontendApi/modules/v1/controllers/UserController.php

@@ -11,9 +11,13 @@ namespace frontendApi\modules\v1\controllers;
 use common\helpers\Cache;
 use common\helpers\Form;
 use common\helpers\user\Info;
+use common\models\Config;
+use common\models\DeclarationLevel;
 use common\models\DeclarationPackage;
+use common\models\DecOrder;
 use common\models\forms\DeclarationForm;
 use common\models\forms\DeclarationLoopForm;
+use common\models\forms\DeclarationUpgradeForm;
 use common\models\forms\UploadForm;
 use common\models\forms\UserBindForm;
 use common\models\forms\UserForm;
@@ -21,6 +25,7 @@ use common\models\OpenBank;
 use common\models\ReceiveAddress;
 use common\models\Region;
 use common\models\ShopGoods;
+use common\models\UpgradeType;
 use common\models\User;
 use common\models\UserBind;
 use common\models\UserInfo;
@@ -126,7 +131,7 @@ class UserController extends BaseController {
             $formModel->scenario = 'idCardFront';
             $formModel->file = UploadedFile::getInstanceByName('file');
             //$formModel->token = \Yii::$app->request->post('uploadToken');
-            $formModel->token = \Yii::$app->request->request('uploadToken');;
+            $formModel->token = \Yii::$app->request->request('uploadToken');
             if ($formModel->file && $formModel->upload()) {
                 return static::notice('上传成功');
             } else {
@@ -199,6 +204,113 @@ class UserController extends BaseController {
         return static::notice(['userBinds' => $userBinds,'mainUid'=>$userBind['MAIN_UID']]);
     }
 
+    // 会员升级,通过会员的编号,获取会员信息
+    public function actionUpgradeInfo() {
+        $userNumber = \Yii::$app->request->request('userName');
+        $baseInfo = Info::baseInfoZhByUserName($userNumber);
+        if ($baseInfo['STATUS'] != 1) {
+            return static::notice('非激活用户,请联系客服',400);
+        }
+        // 1. 如果是最高级别,则只显示用户基本信息
+        // 2. 如果不是最高级别,如果用户累计报单数据是0, 或者用户累计报单业绩不符合级别信息,则提示 请联系客服核对业绩
+        $userId = $baseInfo['ID'];
+        $userDecId = $baseInfo['DEC_LV'];// 用户当前的级别
+        // 获取系统中的DEC 报单级别配置
+        $decConfig = Cache::getDecLevelConfig();
+        $userDecInfo = $decConfig[$userDecId]; // 会员的级别具体信息
+        $maxPerfInfo = DeclarationLevel::getMaxDecPref(); 
+        $maxDecId = $maxPerfInfo['ID']; // 级别配置中最高级别ID
+        $observe = Config::getConfigByType('observe'); // 获取观察期配置信息
+        $observeLimit = $observe['observePeriodLimit']['value']; // 月份限制
+        $isObserve = User::checkIsObserve($baseInfo['CREATED_AT'], $observeLimit); // 判断用户是否再观察期中
+        // var_dump($isObserve);exit;
+        // 如果用户已经是最高级别,则只展示用户信息
+        $isMax = false;
+        if ($maxDecId == $userDecId) {
+            $isMax = true;
+        }
+        $userInfo = [
+            'DEC_NAME' => $baseInfo['DEC_LV_NAME'], // 用户级别中文
+            'DEC_ID' => $userDecId, // 用户级别id
+            'REAL_NAME' => $baseInfo['REAL_NAME'], // 真实姓名
+            'ADD_AT' => date('Y-m-d', $baseInfo['CREATED_AT']), // 加入时间
+            'IS_OBSERVE' => $isObserve, // 是否是观察期  true为是观察期
+            'IS_MAX' => $isMax, // 是否已是最大级别 最大级别不需要判断报单总PV是多少 只展示基本信息
+        ];
+        // 如果是最高级别了,则无需升级
+        if ($isMax) {
+            return static::notice(['baseInfo' => $userInfo]);
+        }
+        $levelPerf = $userDecInfo['PERF'];// 用户当前级别对应的业绩值
+        if (!$isMax) {
+            $userDecPvSum = User::sumDevPvByUserId($userId); // 用户所有报单PV总和
+            // // 如果总和小于级别业绩 去掉这校验直接补比如3000-980的差值
+            // if ($userDecPvSum < $levelPerf) {
+            //     return static::notice('请联系客服人员核对业绩',400);
+            // }
+            $nextLevelPerf = DeclarationLevel::getNextDecPref($levelPerf)['PERF'];
+            // 如果总和超过了下一级业绩
+            if ($userDecPvSum >= $nextLevelPerf) {
+                return static::notice('请联系客服人员核对业绩',400);
+            }
+            $type = $isObserve ? 1 : 2;
+            $userInfo['UPGRADE_FUNC'] = $isObserve ? '补差额升级' : '全额升级';// 升级方式
+            $upgradeType = UpgradeType::getOneByType($type);
+            // 如果用户不是最大级别,则需要获取是否观察期,算出PV是否有问题,应该补多少,
+            $userInfo['UPGRADE_TYPE'] = $upgradeType;
+            $userInfo['NOW_PERF'] = $userDecPvSum;
+            $userInfo['NEXT_PERF'] =  $nextLevelPerf;
+            $userInfo['LEVEL_LIST'] = DeclarationLevel::getNextAll($levelPerf);// 用户可选择的级别列表
+            // 循环列表,补充升级所需要的补差.全额升级则不需计算差值
+            foreach ($userInfo['LEVEL_LIST'] as &$v) {
+                $v['REPAIR_PV'] = $isObserve ? $v['PERF'] - $userInfo['NOW_PERF'] : $v['PERF'];
+            }
+        }
+        
+        return static::notice(['baseInfo' => $userInfo]);
+    }
+
+    // 会员升级管理
+    public function actionUpgrade() {
+        if (\Yii::$app->request->isPost) {
+            // 开始升级
+            $formModel = new DeclarationUpgradeForm();
+            $post = \Yii::$app->request->post();
+            $post['type'] = DeclarationForm::TYPE_ZC;
+            $allData['data'][] = $post;
+            if ($formModel->load($post, '') && $formModel->add($post)) {
+                return static::notice('升级报单成功');
+            } else {
+                return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
+            }
+        }
+
+        //所有报单套餐
+        $allDecPackage = DeclarationPackage::getAllData();
+        $decLevels = Cache::getDecLevelConfig();
+        foreach ($allDecPackage as $k=>$v){
+            $levelName = $decLevels[$v['LEVEL_ID']]['LEVEL_NAME'] ?? '';
+            $allDecPackage[$k]['LEVEL_NAME'] = $levelName;
+        }
+        //所有自选商品
+        $isDecReg = Cache::getSystemConfig()['isDecReg']['VALUE'];
+        $isDec = User::getEnCodeInfo(\Yii::$app->user->id)['IS_DEC'];
+        $isStudio = User::getEnCodeInfo(\Yii::$app->user->id)['IS_STUDIO'];
+        $decUserName = User::getEnCodeInfo(\Yii::$app->user->id)['USER_NAME'];
+        $query_condition= " AND (1<>1";
+        if(!$isDecReg || ($isDecReg && $isDec==1)){
+            $query_condition = " AND (FIND_IN_SET(1,GIFT_TYPE)>0";
+        }
+        if($isStudio==1){
+            $query_condition.= " OR FIND_IN_SET(3,GIFT_TYPE)>0";
+        }
+        $query_condition.= ")";
+
+        $allGoods = ShopGoods::find()->where("STATUS=1 ".$query_condition)->orderBy('SORT ASC')->asArray()->all();
+        return static::notice(['allDecPackage' => $allDecPackage,'allGoods' => $allGoods,'decUserName'=>$decUserName]);
+    }
+
+
     /**
      * 报单管理
      */

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

@@ -207,6 +207,19 @@ export const constantRouterMap = [
           ],
         },
       },
+      {
+        path: '/user/upgrade',
+        component: _import('user/upgrade'),
+        name: 'user_upgrade',
+        meta: {
+          title: '升级管理',
+          highLight: '/user/bind',
+          breadcrumb: [
+            {title: '首页', path: '/dashboard/index'},
+            {title: '会员管理', path: '/user/index'},
+          ],
+        },
+      },
       {
         path: '/user/dec',
         component: _import('user/dec'),

+ 467 - 0
frontendEle/src/views/user/upgrade.vue

@@ -0,0 +1,467 @@
+<template>
+    <div v-loading="loading">
+        <div class="white-box">
+            <el-form :model="form" ref="form"  label-width="250px" class="form-page">
+                <div class="hr-tip"><span>会员信息</span></div>
+                <el-form-item label="会员编号" prop="insertUserName">
+                    <el-input v-model="form.insertUserName" 
+                    placeholder="请输入要升级的会员编号"
+                    :rules="{ required: true, message: '请输入升级的会员编号', trigger: 'blur' }" 
+                    @blur="upgradeInfo()"
+                    >
+                    </el-input>
+                </el-form-item>
+                <el-form-item label="会员级别">
+                    <el-input v-model="form.userDecName" 
+                    disabled
+                    >
+                    </el-input>
+                </el-form-item>
+                <el-form-item label="会员姓名">
+                    <el-input v-model="form.userRealName" 
+                    disabled
+                    >
+                    </el-input>
+                </el-form-item>
+                <el-form-item label="加入日期">
+                    <el-input v-model="form.addAt" 
+                    disabled
+                    >
+                    </el-input>
+                </el-form-item>
+                <el-form-item v-if="!isMax" label="升级方式">
+                    <el-input v-model="form.upgradeFunc" 
+                    disabled
+                    >
+                    </el-input>
+                </el-form-item>
+                <el-form-item v-if="!isMax" label="升级级别" prop="upgradeValue">
+                    <el-select v-model="form.upgradeValue" placeholder="请选择级别" @change="changeLevel">
+                        <el-option
+                        v-for="item in upgradeOption"
+                        :key="item.ID"
+                        :label="item.LEVEL_NAME"
+                        :value="{value:item.ID, diffPv:item.REPAIR_PV}">
+                        </el-option>
+                    </el-select>
+                </el-form-item>
+                <el-form-item v-if="!isMax" label="升级补差业绩">
+                    <el-input v-model="needDiffPv" 
+                    disabled
+                    >
+                    </el-input>
+                </el-form-item>
+
+                <el-form-item v-if="!isMax">
+                    <template slot="label">
+                        升级购买商品
+                    </template>
+                    <el-tabs type="border-card" v-model="decWay" style="position: relative;width: 600px;">
+                        <!-- <el-tab-pane name="1">
+                            <span slot="label">套餐</span>
+                            <el-table class="table-box" :data="_tableData" stripe style="width: 100%;" highlight-current-row @current-change="handleCurrentChange">
+                                <el-table-column
+                                        type="index"
+                                        width="50">
+                                </el-table-column>
+                            <el-table-column label=" " width="50">
+                                <template slot-scope="scope">
+                                    <span class="el-checkbox__input" :class="{'is-checked':scope && scope.row && currentRow && scope.row.ID==currentRow.ID}">
+                                    <span class="el-checkbox__inner">
+                                    </span>
+                                    <input type="checkbox" aria-hidden="false" class="el-checkbox__original" value="">
+                                    </span>
+                                </template>
+                            </el-table-column>
+                            <el-table-column label="套餐名称" prop="PACKAGE_NAME">
+                            </el-table-column>
+                            <el-table-column label="套餐金额" prop="AMOUNT">
+                            </el-table-column>
+                            <el-table-column label="套餐PV" prop="PV">
+                                <template>
+                                </template>
+                            </el-table-column>
+                            <el-table-column label="所属报单级别" prop="LEVEL_NAME">
+                                <template>
+                                </template>
+                            </el-table-column>
+                            <el-table-column label="套餐内容" prop="PACKAGE_CONTENT">
+                                <template >
+                                </template>
+                            </el-table-column>
+                        </el-table>
+                        </el-tab-pane> -->
+                        <el-tab-pane label="商品" name="2">
+                            <el-table class="table-box" v-if="numList.length > 0" :data="tableDatas" stripe style="width: 100%;" highlight-current-row  @selection-change="handleSelectionChange">
+                                <el-table-column
+                                        type="selection"
+                                        width="55">
+                                </el-table-column>
+
+                                <el-table-column label="商品名称" prop="GOODS_NAME">
+
+                                </el-table-column>
+                                <el-table-column label="商品编号" prop="GOODS_NO">
+
+                                </el-table-column>
+                                <el-table-column label="卖价" prop="SELL_PRICE">
+
+                                </el-table-column>
+                                <el-table-column label="PV价格" prop="PRICE_PV">
+
+                                </el-table-column>
+                                <el-table-column label="数量" width="150">
+                                    <template slot-scope="scope">
+                                        <el-input-number size="mini" v-model="numList[scope.$index]"  :min="0" :max="Number(scope.row.STORE_NUMS)" @change="value=>{handleChange(value,scope.row.ID)}"></el-input-number>
+                                    </template>
+                                </el-table-column>
+                            </el-table>
+                            <div class="white-box-footer flex">
+                                <el-button @click="getSum()">计算合计</el-button>
+                                <div class='flex data' style="flex:1;justify-content: flex-end;">
+                                    <div style="margin-right:2rem">商品价格:¥{{sell_price_sum}}</div>
+                                    <div>商品PV:¥{{price_pv_sum}}</div>
+                                </div>
+                            </div>
+                        </el-tab-pane>
+                    </el-tabs>
+                </el-form-item>
+                <el-form-item v-if="!isMax">
+                    <template slot="label">
+                        收货人
+                    </template>
+                    <el-input v-model="form.consignee"></el-input>
+                </el-form-item>
+                <el-form-item v-if="!isMax">
+                    <template slot="label">
+                        收货人手机
+                    </template>
+                    <el-input v-model="form.acceptMobile"></el-input>
+                </el-form-item>
+                <el-form-item v-if="!isMax" prop="areaSelected">
+                    <template slot="label">
+                        地区
+                    </template>
+                    <el-cascader
+                            size="large"
+                            :options="regionData"
+                            v-model="form.areaSelected">
+                    </el-cascader>
+                </el-form-item>
+                <el-form-item v-if="!isMax">
+                    <template slot="label">
+                        详细地址
+                    </template>
+                    <el-input v-model="form.address"></el-input>
+                </el-form-item>
+                <el-form-item v-if="!isMax" label="备注">
+                    <el-input type="textarea" v-model="form.remark"></el-input>
+                </el-form-item>
+                <el-form-item v-if="!isMax">
+                    <el-button type="primary" @click="onSubmit" :loading="submitButtonStat">保存</el-button>
+                </el-form-item>
+            </el-form>
+        </div>
+    </div>
+</template>
+
+<script>
+    import Vue from 'vue'
+    import network from '@/utils/network'
+    import baseInfo from '@/utils/baseInfo'
+    import store from '@/utils/vuexStore'
+     import tool from '@/utils/tool'
+
+    export default {
+        name: 'user_upgrade',
+        mounted() {
+            this.getData()
+        },
+        computed:{
+            _tableData(){
+                if(this.tableData==null){
+                    return [];
+                }
+                if(this.form.decLv==''){
+                    return this.tableData;
+                }
+                return this.tableData.filter(item=>{
+                    return item.LEVEL_ID == this.form.decLv
+                })
+            }
+        },
+
+        data() {
+            return {
+                nowPerf:'',
+                nextPerf:'',
+                decUserName:'',
+                needDiffPv:'',
+                isMax:true,
+                upgradeOption:[],
+                toLevel:'',
+                currentRow:null,
+                decWay:'2',
+                regionData: store.state.regionInfo.regionData,
+                form: {
+                    address:'',
+                    areaSelected:[],
+                    consignee:'',
+                    upgradeFunc:'',
+                    upgradeValue:'',
+                    addAt:'',
+                    userRealName:'',
+                    userDecName:'',
+                    remark:'',
+                    realName:'',
+                    decLv: '',
+                    insertUserName:'',
+                    decUserName:'',
+                    recUserName:'',
+                    conUserName:'',
+                    insertUserIdCard:'',
+                    packageId:'',
+                    goodsId:[],
+                    goodsNum:[],
+                    province:'',
+                    city:'',
+                    county:'',
+                    acceptMobile:'',
+                    
+                },
+                num: 1,
+                tableData:null,
+                tableDatas:null,
+                allDecPackage:{},
+                loading: false,
+                submitButtonStat: false,
+                submitButton:false,
+                allGoods:[],
+                multipleSelection: [],
+                goodsNums:[],
+                numList: [],
+                sell_price_sum:0.00,
+                price_pv_sum:0.00
+            }
+        },
+        methods: {
+            // 获取要升级的会员信息
+            upgradeInfo() {
+                if (this.form.insertUserName) {
+                    network.postData(`user/upgrade-info`,{userName:this.form.insertUserName}).then(response => {
+                        this.form.addAt=response.baseInfo.ADD_AT
+                        this.form.userRealName=response.baseInfo.REAL_NAME
+                        this.form.userDecName=response.baseInfo.DEC_NAME
+                        this.isMax = response.baseInfo.IS_MAX
+                        this.upgradeOption = response.baseInfo.LEVEL_LIST
+                        this.form.upgradeFunc = response.baseInfo.UPGRADE_FUNC //upgradeFunc升级方式
+                        this.nowPerf = response.baseInfo.NOW_PERF // 用户当前业绩
+                        this.nextPerf = response.baseInfo.NEXT_PERF
+                    })
+                }
+            },
+            changeLevel(data) {
+                let { value,diffPv } = data
+                this.needDiffPv = diffPv
+                this.toLevel = value
+            },
+            getSum(){
+                let sell_price_sum=0,price_pv_sum=0;
+                this.multipleSelection.map((item,index)=>{
+                    sell_price_sum+=Number(item.SELL_PRICE)*item.goodsNum;
+                    price_pv_sum+=Number(item.PRICE_PV)*item.goodsNum;
+                })
+                this.sell_price_sum=tool.formatPrice(sell_price_sum);
+                this.price_pv_sum=tool.formatPrice(price_pv_sum);
+            },
+            getData () {
+                network.getData(`user/upgrade`).then(response => {
+                    this.decUserName = response.decUserName
+                    this.loading = false;
+                    this.allDecPackage = response.allDecPackage;
+                    this.allGoods = response.allGoods;
+                    let settingObj=this.allDecPackage;
+                    let settingArr = Object.keys(settingObj).map(key => {
+                        //console.log(key); //为每个键名
+                        return settingObj[key];  //把每个对象返回出去生成一个新的数组中相当于0:{id:1}
+                    });
+                    this.tableData=settingArr;
+                    let settingObj1=this.allGoods;
+                    for(let i in settingObj1){
+                        this.numList[i] = 1;
+                        settingObj1[i].goodsNum= 1 ;
+                    }
+                     this.tableDatas=settingObj1;
+                }).catch(() => {
+                });
+            },
+            handleCurrentChange(val) {
+                console.log(val)
+                if(!val){return}
+                this.currentRow = val;
+                this.form.packageId=this.currentRow.ID;
+
+                console.log(this.form.packageId)
+            },
+            handleSelectionChange(val) {
+                let idx = -1,num;
+                for(let i in this.tableDatas){
+                    for(let v in val){
+                        if(val[v].ID==this.tableDatas[i].ID){
+                            idx = i;
+                            num = this.numList[idx];
+                            val[v]["goodsNum"] = num;
+                            break;
+                        }
+                    }
+                }
+                console.log(val)
+                this.multipleSelection = val;
+                
+            },
+            handleChange(value,ID) {
+                for(let i in this.multipleSelection){
+                    if(this.multipleSelection[i]['ID']==ID) {
+                        this.multipleSelection[i]["goodsNum"] = value;
+                    }
+                }
+            },
+            getGoods(){
+                this.form.goodsId=[];
+                this.form.goodsNum=[];
+                this.multipleSelection.map((item,index)=>{
+                    console.log(item);
+                    console.log('==');
+                    this.form.goodsId.push(item.ID)
+                    this.form.goodsNum.push(item.goodsNum)
+            })
+            },
+            onSubmit() {
+                if (!this.form.insertUserName) {
+                    this.$message({
+                        message: '请输入会员编号',
+                        type: 'error'
+                    })
+                    return false;
+                }
+                if (!this.toLevel) {
+                    this.$message({
+                        message: '请选择级别',
+                        type: 'error'
+                    })
+                    return false
+                }
+                
+                this.getGoods();
+                this.submitButtonStat = true
+                let path = 'user/upgrade'
+                let postData = {
+                    decUserName:this.decUserName,
+                    packageId: this.form.packageId,
+                    goodsId: this.form.goodsId,
+                    goodsNum: this.form.goodsNum,
+                    decWay:this.decWay,
+                    decLv:this.toLevel, // 用户想升级到什么级别
+                    insertUserName:this.form.insertUserName, // 要升级的用户的编号
+                    remark:this.form.remark,
+                    address: this.form.address,
+                    consignee: this.form.consignee,
+                    acceptMobile: this.form.acceptMobile,
+                    province: this.form.areaSelected[0] ? this.form.areaSelected[0] : '',
+                    city: this.form.areaSelected[1] ? this.form.areaSelected[1] : '',
+                    county: this.form.areaSelected[2] ? this.form.areaSelected[2] : '',
+                    nowPerf:this.nowPerf,
+                    nextPerf:this.nextPerf
+                }
+
+                return network.postData(path, postData).then(response => {
+                    console.log(response);
+                    this.$message({
+                        message: response,
+                        type: 'success'
+                    })
+                    this.submitButtonStat = false
+                    this.$router.go(-1)
+                }).catch(() => {
+                    this.submitButtonStat = false
+                })
+            },
+
+            selectOne(event, item) {
+                network.getData(`user/upgrade`).then(response => {
+
+                })
+
+            },
+
+            handleChkConUser() {
+                if (this.form.conUserName) {
+                    this.loading = true
+                    network.getData('user/full-info', {userName: this.form.conUserName}).then(response => {
+                        this.conRealName = response.REAL_NAME + response.isLocation
+                        this.loading = false
+                    }).catch(response => {
+                        this.conRealName = '-'
+                        this.loading = false
+                    })
+                }
+            },
+
+            handleChkRecUser() {
+                if (this.form.recUserName) {
+                    this.loading = true
+                    network.getData('user/full-info', {userName: this.form.recUserName}).then(response => {
+                        this.recRealName = response.REAL_NAME
+                        this.loading = false
+                    }).catch(response => {
+                        this.recRealName = '-'
+                        this.loading = false
+                    })
+                }
+            },
+        }
+    }
+</script>
+
+<style>
+    .hr-tip {
+        font-size: 12px;
+        position: relative;
+        text-align: center;
+        height: 30px;
+        line-height: 30px;
+        color: #999;
+        margin-bottom: 20px;
+    }
+
+    .hr-tip:before {
+        content: '';
+        display: block;
+        position: absolute;
+        left: 0;
+        right: 0;
+        top: 14px;
+        border-bottom: 1px dashed #ddd;
+        height: 1px;
+    }
+
+    .hr-tip span {
+        display: inline-block;
+        background: #fff;
+        position: relative;
+        padding: 0 10px;
+    }
+    .el-input-number--mini .el-input-number__decrease, .el-input-number--mini .el-input-number__increase{width: 22px!important}
+    .el-input-number.is-controls-right .el-input__inner{padding-left: 10px;
+        padding-right: 30px;}
+    .el-tabs--border-card{
+        position: relative;
+    width: 600px;
+    }
+    .flex{
+        display: flex;
+    }
+    .form-page{
+        width:100% !important;
+    }
+</style>