toData('400','surname 参数无效'); } if(empty($params['name']) || !is_string($params['name'])){ return $this->toData('400','name 参数无效'); } if(empty($params['code']) || !is_string($params['code'])){ return $this->toData('400','code 参数无效'); } if(empty($params['country']) || !is_numeric($params['country'])){ return $this->toData('400','country 参数无效'); } if(empty($params['front_img'])){ return $this->toData('400','front_img 参数无效'); } if (empty($params['birth_day'])) { return $this->toData('400','birth_day 参数无效'); } if (empty($params['gender'])) { return $this->toData('400','gender 参数无效'); } if (empty($params['addr'])) { return $this->toData('400','addr 参数无效'); } if (empty($params['zip_code'])) { return $this->toData('400','zip_code 参数无效'); } if (empty($params['email'])) { return $this->toData('400','email 参数无效'); } if (empty($params['email_code'])) { return $this->toData('400','email_code 参数无效'); } // if(empty($params['back_img']) || !is_numeric($params['back_img'])){ // return $this->toData('100400','Invalid back_img'); // } // 判断用户状态 $user = UserModel::where('user_id', $userId)->find(); if(empty($user)){ return $this->toData('500','用户数据为空'); } // 判断是是否已经认证 if($user->is_real == 1){ return $this->toData('500','Real name authentication has been passed'); } // 是否是未认证或者认证失败状态 if($user->real_status == 2 || $user->real_status == 3){ return $this->toData('500','status error'); } $country = CountryModel::where('id',$params['country'])->find(); if(empty($country)){ return $this->toData('500','country error'); } // 验证邮箱 $emailKey = 'USER:sendEmailLoginNoTrade:' . $params['email']; $cacheCode = Cache::store('redis')->get($emailKey); if (empty($cacheCode) || $cacheCode != $params['email_code']) { return $this->toData('500','邮箱验证码不通过'); } // 写入数据库 $userVerify = new UserVerifyLogModel; $userVerify->user_id = $userId; $userVerify->country = $params['country']; $userVerify->code = $params['code']; $userVerify->surname = $params['surname']; $userVerify->name = $params['name']; $userVerify->front_img = $params['front_img']; $userVerify->back_img = $params['back_img'] ?? ""; $userVerify->create_time = date('Y-m-d H:i:s'); $userVerify->update_time = date('Y-m-d H:i:s'); $userVerify->birth_day = $params['birth_day']; $userVerify->gender = $params['gender']; $userVerify->addr = $params['addr']; $userVerify->zip_code = $params['zip_code']; $userVerify->email = $params['email']; $userVerify->save(); // 更改用户状态 $user->real_status = 2; $user->save(); return $this->toData('0','SUCCESS'); }catch (\Exception $exception){ return $this->toData('100500','The system is busy.'); } } public function detail($userId) { try { $user = UserModel::where('user_id', $userId)->find(); if(empty($user)){ return $this->toData('500','用户数据为空'); } $userVerify = UserVerifyLogModel::where('user_id', $userId)->order('id', 'desc')->find(); if (empty($userVerify)) { return $this->toData('500','用户实名认证数据为空'); } $data = $userVerify->toArray(); $front = AwsS3Model::where('id', $userVerify->front_img)->value('s3_url'); $back = AwsS3Model::where('id', $userVerify->back_img)->value('s3_url'); $country = CountryModel::where('id', $userVerify->country)->find(); $data['country_data'] = $country; $data['front_img'] = $front; $data['back_img'] = $back; return $this->toData('0', 'SUCCESS', $data); }catch (\Exception $exception){ return $this->toData('100500','The system is busy.'); } } }