Browse Source

修改密码去掉规则校验,注册报单修改密码规则

root 3 năm trước cách đây
mục cha
commit
4627715b20

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

+ 2 - 2
frontendEle/src/views/user/dec.vue

@@ -283,8 +283,8 @@
                     bankCounty: '',
                     bankNo: '',
                     bankAreaSelected: [],
-                    password:'111111',
-                    payPassword:'111111',
+                    password:'',
+                    payPassword:'',
                     mobile:'',
                     packageId:'',
                     goodsId:[],