wesmiler 2 роки тому
батько
коміт
c016c01353

+ 2 - 1
app/Http/Validator/MemberValidator.php

@@ -45,7 +45,8 @@ class MemberValidator extends BaseValidator
         'email_login'=> ['email','code'],
         'email_register'=> ['email','code'],
         'email'=> ['email','scene'],
-        'recharge'=> ['usdt']
+        'recharge'=> ['usdt'],
+        'modifyEmail'=> ['email','new_email']
     ];
 
     /**

+ 21 - 30
app/Services/Api/MemberService.php

@@ -685,7 +685,7 @@ class MemberService extends BaseService
      */
     public function modify($userId, $params)
     {
-        $username = isset($params['username']) ? $params['username'] : '';
+        $email = isset($params['email']) ? $params['email'] : '';
         $password = isset($params['password']) ? $params['password'] : '';
         $payPassword = isset($params['pay_password']) ? $params['pay_password'] : '';
 
@@ -713,35 +713,26 @@ class MemberService extends BaseService
             }
         }
 
-        // 用户账号验证
-        if (isset($params['username']) && $username) {
-            $data['username'] = $username;
-            $checkInfo = $this->model->where(['username' => $username, 'mark' => 1])->select(['id', 'status'])->first();
-            if ($checkInfo && $checkInfo['id'] != $userId) {
-                $this->error = 2005;
-                return false;
-            }
-        }
-
-        // 手机号验证
-        $mobile = isset($params['mobile']) ? $params['mobile'] : '';
-        if (isset($params['mobile']) && $mobile) {
-            $data['mobile'] = $mobile;
-            $checkInfo = $this->model->where(['mobile' => $mobile, 'mark' => 1])->select(['id', 'status'])->first();
-            if ($checkInfo && $checkInfo['id'] != $userId) {
-                $this->error = 2009;
-                return false;
+        // 邮箱验证
+        if (isset($params['email']) && $email) {
+            // 修改邮箱
+            $newEmail = isset($params['new_email'])? trim($params['new_email']) : '';
+            if(isset($params['new_email']) && $newEmail){
+                $data['email'] = $email;
+                $data['username'] = $email;
+                $checkInfo = $this->model->where(['username' => $newEmail, 'mark' => 1])->select(['id', 'status'])->first();
+                if ($checkInfo && $checkInfo['id'] != $userId) {
+                    $this->error = 2005;
+                    return false;
+                }
             }
 
-            // 短信验证码
-            $code = isset($params['code']) ? $params['code'] : '';
-            if (empty($code)) {
-                $this->error = 2013;
-                return false;
-            }
 
-            if (!SmsService::make()->check($mobile, $code, 'modify')) {
-                $this->error = SmsService::make()->getError();
+            // 邮箱验证码
+            $code = isset($params['code'])? trim($params['code']) : '';
+            $scene = isset($params['scene'])? trim($params['scene']) : '';
+            if (!EmailService::make()->check($email, $code, $scene)) {
+                $this->error = EmailService::make()->getError();
                 return false;
             }
         }
@@ -752,9 +743,9 @@ class MemberService extends BaseService
             $data['nickname'] = $nickname;
         }
 
-        $sex = isset($params['sex']) ? $params['sex'] : 0;
-        if (isset($params['sex']) && $sex) {
-            $data['sex'] = $sex;
+        $gender = isset($params['gender']) ? intval($params['gender']) : 3;
+        if (isset($params['gender']) && $gender) {
+            $data['gender'] = $gender;
         }
 
         $intro = isset($params['intro']) ? $params['intro'] : '';