1
This commit is contained in:
+105
-55
@@ -36,55 +36,40 @@ class ImService extends BaseService
|
||||
throw new BusinessException("用户数据错误");
|
||||
}
|
||||
|
||||
if ($user['user_type'] == 1){
|
||||
// 患者
|
||||
$params = array();
|
||||
$params['user_id'] = $user['user_id'];
|
||||
$user_patient = UserPatient::getOne($params);
|
||||
if (empty($user_patient)){
|
||||
throw new BusinessException("患者数据错误");
|
||||
}
|
||||
|
||||
$avatar = addAliyunOssWebsite($user_patient['avatar']);
|
||||
$user_name = $user_patient['user_name'];
|
||||
}elseif ($user['user_type'] == 2){
|
||||
// 医生
|
||||
$params = array();
|
||||
$params['user_id'] = $user['user_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)){
|
||||
throw new BusinessException("医生数据错误");
|
||||
}
|
||||
|
||||
$avatar = addAliyunOssWebsite($user_doctor['avatar']);
|
||||
$user_name = $user_doctor['user_name'];
|
||||
}elseif ($user['user_type'] == 3){
|
||||
// 药师
|
||||
$params = array();
|
||||
$params['user_id'] = $user['user_id'];
|
||||
$user_pharmacist = UserPharmacist::getOne($params);
|
||||
if (empty($user_pharmacist)){
|
||||
throw new BusinessException("药师数据错误");
|
||||
}
|
||||
|
||||
$avatar = addAliyunOssWebsite($user_pharmacist['avatar']);
|
||||
$user_name = $user_pharmacist['user_name'];
|
||||
}
|
||||
$avatar = addAliyunOssWebsite($user['avatar']);
|
||||
|
||||
$account = new Account();
|
||||
// 查询账号导入状态
|
||||
$res = $account->checkAccountStatus($user['user_id']);
|
||||
if (!$res){
|
||||
// 创建单个账号
|
||||
$account->createAccount($user_id,$user_name,$avatar);
|
||||
$account->createAccount($user_id,$user['user_name'],$avatar);
|
||||
}
|
||||
|
||||
// 医生检测并设置资料
|
||||
if ($user['user_type'] == 2){
|
||||
// 检测用户资料
|
||||
$profile = new Profile();
|
||||
$result = $profile->getOneAccountPortraitList($user['user_id']);
|
||||
if (!empty($result)){
|
||||
// 检测用户资料
|
||||
$profile = new Profile();
|
||||
$result = $profile->getOneAccountPortraitList($user['user_id']);
|
||||
if (!empty($result)){
|
||||
$arg = array();
|
||||
|
||||
// 头像
|
||||
if (in_array('Tag_Profile_IM_Image',$result)){
|
||||
$arg['Tag_Profile_IM_Image'] = $avatar;
|
||||
}
|
||||
|
||||
// 性别
|
||||
if (in_array('Tag_Profile_IM_Gender',$result)){
|
||||
$arg['Tag_Profile_IM_Gender'] = sexToImSex($user['sex']);
|
||||
}
|
||||
|
||||
if ($user['user_type'] == 2){
|
||||
$params = array();
|
||||
$params['user_id'] = $user['user_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)){
|
||||
throw new BusinessException("医生数据错误");
|
||||
}
|
||||
|
||||
// 获取订单医生医院
|
||||
$params = array();
|
||||
$params['hospital_id'] = $user_doctor['hospital_id'];
|
||||
@@ -93,11 +78,77 @@ class ImService extends BaseService
|
||||
throw new BusinessException("医生医院数据错误");
|
||||
}
|
||||
|
||||
// 设置用户资料
|
||||
$arg = array();
|
||||
// 性别
|
||||
if (in_array('Tag_Profile_IM_Gender',$result)){
|
||||
$arg['Tag_Profile_IM_Gender'] = sexToImSex($user_doctor['sex']);
|
||||
// 医院
|
||||
if (in_array('Tag_Profile_Custom_Hname',$result)){
|
||||
$arg['Tag_Profile_Custom_Hname'] = $hospital['hospital_name'];
|
||||
}
|
||||
|
||||
// 职称
|
||||
if (in_array('Tag_Profile_Custom_Title',$result)){
|
||||
$arg['Tag_Profile_Custom_Title'] = $user_doctor['doctor_title'] ?? DoctorTitleCode::getMessage($user_doctor['doctor_title']);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($arg)){
|
||||
$profile->setProfile($user['user_id'],$arg);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户资料
|
||||
* @param string $user_id
|
||||
* @return bool
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function setUserProfile(string $user_id): bool
|
||||
{
|
||||
try {
|
||||
$params = array();
|
||||
$params['user_id'] = $user_id;
|
||||
$user = User::getOne($params);
|
||||
if (empty($user)){
|
||||
throw new BusinessException("用户数据错误");
|
||||
}
|
||||
|
||||
$avatar = addAliyunOssWebsite($user['avatar']);
|
||||
|
||||
// 检测用户资料
|
||||
$profile = new Profile();
|
||||
$result = $profile->getOneAccountPortraitList($user['user_id']);
|
||||
|
||||
if (!empty($result)){
|
||||
$arg = array();
|
||||
|
||||
// 头像
|
||||
if (in_array('Tag_Profile_IM_Image',$result)){
|
||||
$arg['Tag_Profile_IM_Image'] = $avatar;
|
||||
}
|
||||
|
||||
// 性别
|
||||
if (in_array('Tag_Profile_IM_Gender',$result)){
|
||||
$arg['Tag_Profile_IM_Gender'] = sexToImSex($user['sex']);
|
||||
}
|
||||
|
||||
if ($user['user_type'] == 2){
|
||||
$params = array();
|
||||
$params['user_id'] = $user['user_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)){
|
||||
throw new BusinessException("医生数据错误");
|
||||
}
|
||||
|
||||
// 获取订单医生医院
|
||||
$params = array();
|
||||
$params['hospital_id'] = $user_doctor['hospital_id'];
|
||||
$hospital = Hospital::getOne($params);
|
||||
if (empty($hospital)){
|
||||
throw new BusinessException("医生医院数据错误");
|
||||
}
|
||||
|
||||
// 医院
|
||||
@@ -106,13 +157,13 @@ class ImService extends BaseService
|
||||
}
|
||||
|
||||
// 职称
|
||||
if (in_array('Tag_Profile_Custom_Hname',$result)){
|
||||
if (in_array('Tag_Profile_Custom_Title',$result)){
|
||||
$arg['Tag_Profile_Custom_Title'] = $user_doctor['doctor_title'] ?? DoctorTitleCode::getMessage($user_doctor['doctor_title']);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($arg)){
|
||||
$profile->setProfile($user_doctor['user_id'],$arg);
|
||||
}
|
||||
if (!empty($arg)){
|
||||
$profile->setProfile($user['user_id'],$arg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +171,6 @@ class ImService extends BaseService
|
||||
} catch (\Exception $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,12 +228,12 @@ class ImService extends BaseService
|
||||
public function sendTextMessage(string $from_user_id,string $to_user_id,string $content,string $order_inquiry_id,int $inquiry_type): void
|
||||
{
|
||||
if (!empty($from_user_id)){
|
||||
// 检测并创建发送者账号
|
||||
$this->createAccount($from_user_id);
|
||||
// 检测并创建发送者资料
|
||||
$this->setUserProfile($from_user_id);
|
||||
}
|
||||
|
||||
// 检测并创建接收者账号
|
||||
$this->createAccount($to_user_id);
|
||||
// 检测并创建接收者资料
|
||||
$this->setUserProfile($to_user_id);
|
||||
|
||||
// 医生给患者发送消息
|
||||
$message = new Message();
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Model\DoctorInquiryConfig as DoctorInquiryConfigModel;
|
||||
use App\Model\Module as ModuleModel;
|
||||
use App\Model\PatientHistoryInquiry as PatientHistoryInquiryModel;
|
||||
use App\Model\PharmacistAuditStatistic;
|
||||
use App\Model\User;
|
||||
use App\Model\UserDoctor as UserDoctorModel;
|
||||
use App\Model\UserPharmacist;
|
||||
|
||||
@@ -40,8 +41,6 @@ class IndexService extends BaseService
|
||||
"iden_auth_fail_reason",
|
||||
"multi_point_status",
|
||||
"is_bind_bank",
|
||||
"mobile",
|
||||
"avatar",
|
||||
"praise_rate",
|
||||
"avg_response_time",
|
||||
"number_of_fans",
|
||||
|
||||
@@ -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 Extend\TencentIm\Account;
|
||||
use Extend\Wechat\Wechat;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Redis\Redis;
|
||||
@@ -85,7 +86,6 @@ class LoginService extends BaseService
|
||||
$data['union_id'] = $wx_info_data['unionid'] ?? "";
|
||||
$data['wx_session_key'] = $wx_info_data['session_key'];
|
||||
$data['status'] = 1;
|
||||
$data['mobile'] = $phone_info['phone_info']['purePhoneNumber'];
|
||||
|
||||
if ($user['user_type'] == 1) {
|
||||
// 患者
|
||||
@@ -114,6 +114,11 @@ class LoginService extends BaseService
|
||||
|
||||
$client_user_id = $user_doctor['doctor_id'];
|
||||
}
|
||||
|
||||
// 创建im账号
|
||||
$account = new Account();
|
||||
// 创建单个账号
|
||||
$account->createAccount($user->user_id,$user->user_name,"");
|
||||
} else {
|
||||
// 已注册用户
|
||||
// 重复注册不同端
|
||||
@@ -272,7 +277,6 @@ class LoginService extends BaseService
|
||||
$data['user_id'] = $user->user_id;
|
||||
$data['user_name'] = $user['user_name'];
|
||||
$data['status'] = 1;
|
||||
$data['mobile'] = $phone;
|
||||
|
||||
if ($user['user_type'] == 1) {
|
||||
// 患者
|
||||
|
||||
@@ -2,8 +2,15 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\User;
|
||||
use App\Model\User as UserModel;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Model\UserPatient;
|
||||
use App\Model\UserPharmacist;
|
||||
use Extend\Alibaba\Oss;
|
||||
use Extend\TencentIm\Account;
|
||||
use Extend\TencentIm\Safe;
|
||||
|
||||
/**
|
||||
* 安全服务
|
||||
@@ -67,4 +74,33 @@ class SafeService extends BaseService
|
||||
|
||||
return success($oss->signature($dir));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取im签名数据
|
||||
* @return array
|
||||
*/
|
||||
public function getImSign(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
if (empty($user_info)){
|
||||
return success();
|
||||
}
|
||||
|
||||
// 验证用户数据
|
||||
$params = array();
|
||||
$params['user_id'] = $user_info['user_id'];
|
||||
$user = User::getOne($params);
|
||||
if (empty($user)){
|
||||
return success();
|
||||
}
|
||||
|
||||
$safe = new Safe();
|
||||
$sign = $safe->getUserSign($user['user_id']);
|
||||
if (empty($sign)){
|
||||
return success();
|
||||
}
|
||||
|
||||
return success($sign);
|
||||
}
|
||||
}
|
||||
@@ -1509,7 +1509,7 @@ class UserDoctorService extends BaseService
|
||||
* @param string $inquiry_type
|
||||
* @return string
|
||||
*/
|
||||
public function getInquiryAssignDoctor(string $inquiry_type,): string
|
||||
public function getInquiryAssignDoctor(string $inquiry_type): string
|
||||
{
|
||||
// 获取问诊配置
|
||||
$params = array();
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Model\UserDoctor;
|
||||
use App\Model\UserDoctorInfo;
|
||||
use App\Model\UserPatient;
|
||||
use App\Utils\PcreMatch;
|
||||
use Extend\TencentIm\Profile;
|
||||
use Extend\Wechat\Wechat;
|
||||
use Hyperf\Amqp\Result;
|
||||
use Hyperf\DbConnection\Db;
|
||||
@@ -91,58 +92,83 @@ class UserService extends BaseService
|
||||
// 匹配去除oss网址
|
||||
$avatar = PcreMatch::pregRemoveOssWebsite($avatar);
|
||||
|
||||
// 获取对应用户信息
|
||||
if ($user['user_type'] == 1){
|
||||
// 患者
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 修改用户表
|
||||
$data = array();
|
||||
$data['avatar'] = $avatar;
|
||||
|
||||
$params = array();
|
||||
$params['user_id'] = $user_info['user_id'];
|
||||
$user_patient = UserPatient::getOne($params);
|
||||
if (empty($user_patient)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
if ($user_patient['avatar'] != $avatar) {
|
||||
$data = array();
|
||||
$data['avatar'] = $avatar;
|
||||
User::editUser($params,$data);
|
||||
|
||||
// 获取对应用户信息
|
||||
if ($user['user_type'] == 1){
|
||||
// 患者
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_patient['patient_id'];
|
||||
UserPatient::editUserPatient($params,$data);
|
||||
}
|
||||
}elseif ($user['user_type'] == 2){
|
||||
// 医生
|
||||
$params = array();
|
||||
$params['user_id'] = $user_info['user_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)){
|
||||
return fail();
|
||||
}
|
||||
$params['user_id'] = $user_info['user_id'];
|
||||
$user_patient = UserPatient::getOne($params);
|
||||
if (empty($user_patient)){
|
||||
Db::rollBack();
|
||||
return fail();
|
||||
}
|
||||
|
||||
if ($user_doctor['avatar'] != $avatar) {
|
||||
$data = array();
|
||||
$data['avatar'] = $avatar;
|
||||
if ($user_patient['avatar'] != $avatar) {
|
||||
$data = array();
|
||||
$data['avatar'] = $avatar;
|
||||
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_patient['patient_id'];
|
||||
UserPatient::editUserPatient($params,$data);
|
||||
}
|
||||
}elseif ($user['user_type'] == 2){
|
||||
// 医生
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_doctor['doctor_id'];
|
||||
UserDoctor::editUserDoctor($params,$data);
|
||||
}
|
||||
}elseif ($user['user_type'] == 3){
|
||||
// 药师
|
||||
$params = array();
|
||||
$params['user_id'] = $user_info['user_id'];
|
||||
$user_pharmacist = UserPatient::getOne($params);
|
||||
if (empty($user_pharmacist)){
|
||||
return fail();
|
||||
}
|
||||
$params['user_id'] = $user_info['user_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)){
|
||||
Db::rollBack();
|
||||
return fail();
|
||||
}
|
||||
|
||||
if ($user_pharmacist['avatar'] != $avatar) {
|
||||
$data = array();
|
||||
$data['avatar'] = $avatar;
|
||||
if ($user_doctor['avatar'] != $avatar) {
|
||||
$data = array();
|
||||
$data['avatar'] = $avatar;
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_doctor['doctor_id'];
|
||||
UserDoctor::editUserDoctor($params,$data);
|
||||
}
|
||||
}elseif ($user['user_type'] == 3){
|
||||
// 药师
|
||||
$params = array();
|
||||
$params['pharmacist_id'] = $user_pharmacist['pharmacist_id'];
|
||||
UserPatient::editUserPatient($params,$data);
|
||||
$params['user_id'] = $user_info['user_id'];
|
||||
$user_pharmacist = UserPatient::getOne($params);
|
||||
if (empty($user_pharmacist)){
|
||||
Db::rollBack();
|
||||
return fail();
|
||||
}
|
||||
|
||||
if ($user_pharmacist['avatar'] != $avatar) {
|
||||
$data = array();
|
||||
$data['avatar'] = $avatar;
|
||||
|
||||
$params = array();
|
||||
$params['pharmacist_id'] = $user_pharmacist['pharmacist_id'];
|
||||
UserPatient::editUserPatient($params,$data);
|
||||
}
|
||||
}
|
||||
|
||||
// 修改im头像
|
||||
$profile = new Profile();
|
||||
$arg = array();
|
||||
$arg['Tag_Profile_IM_Image'] = addAliyunOssWebsite($avatar);
|
||||
$profile->setProfile($user_info['user_id'],$arg);
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
|
||||
}
|
||||
|
||||
return success();
|
||||
|
||||
Reference in New Issue
Block a user