新增手机号登录获取openid、新增身份认证科室验证
This commit is contained in:
@@ -739,6 +739,11 @@ class DoctorAuthService extends BaseService
|
||||
$result['department_custom_mobile_reason'] = $doctor_iden_fail['fail_reason'];
|
||||
}
|
||||
|
||||
// 科室名称
|
||||
if ($doctor_iden_fail['field_name'] == "department_custom_name") {
|
||||
$result['department_custom_name_reason'] = $doctor_iden_fail['fail_reason'];
|
||||
}
|
||||
|
||||
// 医生简介
|
||||
if ($doctor_iden_fail['field_name'] == "brief_introduction") {
|
||||
$result['brief_introduction_reason'] = $doctor_iden_fail['fail_reason'];
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Model\UserPatient as UserPatientModel;
|
||||
use App\Model\UserPharmacist as UserPharmacistModel;
|
||||
use App\Utils\Http;
|
||||
use App\Utils\Jwt;
|
||||
use App\Utils\Log;
|
||||
use Extend\TencentIm\Account;
|
||||
use Extend\Wechat\Wechat;
|
||||
use Hyperf\DbConnection\Db;
|
||||
@@ -232,17 +233,31 @@ class LoginService extends BaseService
|
||||
$code = $this->request->input('code');
|
||||
$phone = $this->request->input('phone');
|
||||
$user_type = $this->request->input('user_type');
|
||||
$wx_code = $this->request->input('wx_code');
|
||||
|
||||
$redis = $this->container->get(Redis::class);
|
||||
// 验证验证码
|
||||
// $sms_code = $redis->get("login_code" . $phone);
|
||||
// if (empty($sms_code)){
|
||||
// return fail(HttpEnumCode::CODE_EXPIRED);
|
||||
// }
|
||||
//
|
||||
// if ($sms_code != $code){
|
||||
// return fail(HttpEnumCode::CODE_ERROR);
|
||||
// }
|
||||
$sms_code = $redis->get("login_code" . $phone);
|
||||
if (empty($sms_code)){
|
||||
return fail(HttpEnumCode::CODE_EXPIRED);
|
||||
}
|
||||
|
||||
if ($sms_code != $code){
|
||||
return fail(HttpEnumCode::CODE_ERROR);
|
||||
}
|
||||
|
||||
try {
|
||||
$weChat = new Wechat($user_type);
|
||||
|
||||
// 获取用户openid
|
||||
$wx_info_data = $weChat->codeToSession($wx_code);
|
||||
$session_key = $wx_info_data['session_key'] ?? "";
|
||||
$open_id = $wx_info_data['openid'] ?? "";
|
||||
} catch (\Exception $e) {
|
||||
// 此处不进行处理
|
||||
Log::getInstance()->info($e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
Db::beginTransaction();
|
||||
|
||||
@@ -277,6 +292,8 @@ class LoginService extends BaseService
|
||||
$data['user_id'] = $user->user_id;
|
||||
$data['user_name'] = $user['user_name'];
|
||||
$data['status'] = 1;
|
||||
$data['open_id'] = $open_id;
|
||||
$data['wx_session_key'] = $session_key;
|
||||
|
||||
if ($user['user_type'] == 1) {
|
||||
// 患者
|
||||
@@ -303,6 +320,12 @@ class LoginService extends BaseService
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
$client_user_id = $user_doctor['doctor_id'];
|
||||
}elseif($user['user_type'] == 3){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}else{
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
} else {
|
||||
// 已注册用户
|
||||
@@ -329,6 +352,9 @@ class LoginService extends BaseService
|
||||
if (!empty($result)){
|
||||
$client_user_id = $result['pharmacist_id'];
|
||||
}
|
||||
}else{
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
if (empty($result)) {
|
||||
@@ -362,7 +388,7 @@ class LoginService extends BaseService
|
||||
$token_user_data = array();
|
||||
$token_user_data['user_id'] = $user['user_id']; // 用户id
|
||||
$token_user_data['user_type'] = $user['user_type'];// 用户类型
|
||||
$token_user_data['open_id'] = "";// open_id
|
||||
$token_user_data['open_id'] = $open_id;// open_id
|
||||
$token_user_data['client_user_id'] = $client_user_id;// 对应客户端id
|
||||
|
||||
// 发放token
|
||||
|
||||
Reference in New Issue
Block a user