Browse Source

Merge branch 'new-version' into feature/york-1654-jiangjinyincang

root 3 years ago
parent
commit
ce3789f538

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

@@ -588,6 +588,16 @@ class Info {
         return $password;
     }
 
+    // 简单身份证号校验
+    public static function simpleIdCardCheck($idCard) {
+        $regx = '/^\d{6}(19|2\d)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)?$/';
+        if (!preg_match($regx, $idCard)) {
+            return false;
+        }
+
+        return true;
+    }
+
     /**
      * 当时会员级别状态等
      * @param $userId

+ 23 - 4
common/models/forms/DeclarationForm.php

@@ -113,8 +113,8 @@ class DeclarationForm extends Model
     public function rules()
     {
         return [
-            [['type','decLv','decWay','packageId', 'insertUserName', 'realName', 'insertUserIdCard', 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo','bankProvince','bankCity','bankCounty','consignee','acceptMobile','province','city','county','decUserName', 'conUserName', 'recUserName', 'location'], 'trim'],
-            [['type','decLv','decWay','insertUserName', 'insertUserIdCard','password','payPassword','decUserName'], 'required'],
+            [['password','payPassword','type','decLv','decWay','packageId', 'insertUserName', 'realName', 'insertUserIdCard', 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo','bankProvince','bankCity','bankCounty','consignee','acceptMobile','province','city','county','decUserName', 'conUserName', 'recUserName', 'location'], 'trim'],
+            [['type','decLv','decWay','insertUserName', 'insertUserIdCard','decUserName'], 'required'],
             [['type'], 'isType', 'on'=>['userDec', 'canDec']],
             [['insertUserName'], 'isCanAddUser'],
             [['decUserName'], 'issetDec'],
@@ -688,11 +688,30 @@ class DeclarationForm extends Model
      */
     public function addUser($allData){
         $period = Period::instance();
+        $userPasswd = $this->password;
+        $userPayPasswd = $this->payPassword;
+        // 如果身份证信息有误,或不足6位,并且没有手动填写密码,就用111111
+        if (Info::simpleIdCardCheck($this->insertUserIdCard)) {
+            if (empty($userPasswd)) {
+                $userPasswd = Info::passwordGenerator($this->insertUserIdCard,$this->insertUserName);
+            }
+            if (empty($userPayPasswd)) {
+                $userPayPasswd = Info::passwordGenerator($this->insertUserIdCard,$this->insertUserName);
+            }
+        } else {
+            if (empty($userPasswd)) {
+                $userPasswd = '111111';
+            }
+            if (empty($userPayPasswd)) {
+                $userPayPasswd = '111111';
+            }
+        }
+        
         // 增加会员
         $user = new User();
         $user->USER_NAME = $this->insertUserName;
-        $user->PASSWORD_HASH = \Yii::$app->security->generatePasswordHash($this->password);
-        $user->PAY_PASSWORD = \Yii::$app->security->generatePasswordHash($this->payPassword);
+        $user->PASSWORD_HASH = \Yii::$app->security->generatePasswordHash($userPasswd);
+        $user->PAY_PASSWORD = \Yii::$app->security->generatePasswordHash($userPayPasswd);
         $user->NATION = 0;
         $user->REAL_NAME = $this->realName;
         $user->ID_CARD = $this->insertUserIdCard;

+ 10 - 10
common/models/forms/UserForm.php

@@ -581,11 +581,11 @@ class UserForm extends Model
         }
 
         // 进行规则的判断
-        $message = $model->verificationPassword($this->password,$this->scenario,$model);
-        if ( $message['code'] != 200 ){
-            $this->addError($message['type'], $message['message']);
-            return null;
-        }
+        // $message = $model->verificationPassword($this->password,$this->scenario,$model);
+        // if ( $message['code'] != 200 ){
+        //     $this->addError($message['type'], $message['message']);
+        //     return null;
+        // }
 
         $model->PASSWORD_HASH = \Yii::$app->security->generatePasswordHash($this->password);
         if(!$model->save()){
@@ -613,11 +613,11 @@ class UserForm extends Model
         }
 
         // 进行规则的判断
-        $message = $model->verificationPassword($this->payPassword,$this->scenario,$model);
-        if ( $message['code'] != 200 ){
-            $this->addError($message['type'], $message['message']);
-            return null;
-        }
+        // $message = $model->verificationPassword($this->payPassword,$this->scenario,$model);
+        // if ( $message['code'] != 200 ){
+        //     $this->addError($message['type'], $message['message']);
+        //     return null;
+        // }
         $model->PAY_PASSWORD = \Yii::$app->security->generatePasswordHash($this->payPassword);
         if(!$model->save()){
             $this->addErrors($model->getErrors());

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

@@ -339,7 +339,6 @@ class UserController extends BaseController {
             $formModel = new DeclarationLoopForm();
             $formModel->scenario = 'userDec';
             $post = \Yii::$app->request->post();
-
             // 针对于会员编号的判断
             $insertUserName = strtoupper($post['insertUserName']);
             $getRedisUserName = $redis->get('key_'.$insertUserName);

+ 14 - 4
frontendEle/src/views/user/dec.vue

@@ -157,20 +157,23 @@
 
                         身份证号
                     </template>
-                    <el-input v-model="form.insertUserIdCard" maxlength="18"></el-input>
+                    <el-input v-model="form.insertUserIdCard" maxlength="18" @blur="idcarChange"></el-input>
                 </el-form-item>
-
                 <el-form-item>
                     <template slot="label">
                         登录密码
                     </template>
                     <el-input v-model="form.password" maxlength="32" placeholder="请输入密码"></el-input>
+                    <span style="color:red;font-size: 13px;">默认密码为身份证号码后六位
+                    </span>
                 </el-form-item>
                 <el-form-item>
                     <template slot="label">
                         支付密码
                     </template>
                     <el-input v-model="form.payPassword" maxlength="32" placeholder="请输入支付密码"></el-input>
+                    <span style="color:red;font-size: 13px;">默认密码为身份证号码后六位
+                    </span>
                 </el-form-item>
                 <el-form-item>
                     <template slot="label">
@@ -283,8 +286,8 @@
                     bankCounty: '',
                     bankNo: '',
                     bankAreaSelected: [],
-                    password:'111111',
-                    payPassword:'111111',
+                    password:'',
+                    payPassword:'',
                     mobile:'',
                     packageId:'',
                     goodsId:[],
@@ -315,6 +318,13 @@
             }
         },
         methods: {
+            idcarChange() {
+                if (this.form.insertUserIdCard.length >= 6) {
+                    this.form.payPassword = this.form.password = this.form.insertUserIdCard.substring(this.form.insertUserIdCard.length-6,this.form.insertUserIdCard.length);
+                } else {
+                    this.form.payPassword = this.form.password = '111111'
+                }
+            },
             getSum(){
                 let sell_price_sum=0,price_pv_sum=0;
                 this.multipleSelection.map((item,index)=>{