新增审核多点,修改医生多点处理
This commit is contained in:
+249
-155
@@ -128,7 +128,7 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, putUserDoctorRequest r
|
||||
// 获取用户数据
|
||||
userDao := dao.UserDao{}
|
||||
user, err := userDao.GetUserById(userDoctor.UserId)
|
||||
if err != nil {
|
||||
if err != nil && user == nil {
|
||||
return false, errors.New("医生数据错误")
|
||||
}
|
||||
|
||||
@@ -177,6 +177,27 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, putUserDoctorRequest r
|
||||
}
|
||||
}
|
||||
|
||||
// 修改科室数据,重新认定为未审核
|
||||
if userDoctor.DepartmentCustomId != departmentCustomId {
|
||||
// 检测是否存在正在审核中的处方
|
||||
orderPrescriptionDao := dao.OrderPrescriptionDao{}
|
||||
|
||||
maps := make(map[string]interface{})
|
||||
maps["doctor_id"] = doctorId
|
||||
maps["prescription_status"] = 1
|
||||
orderPrescription, err := orderPrescriptionDao.GetList(maps)
|
||||
if err != nil {
|
||||
return false, errors.New("修改失败")
|
||||
}
|
||||
|
||||
if len(orderPrescription) > 0 {
|
||||
return false, errors.New("存在审核中的处方,请勿修改科室数据")
|
||||
}
|
||||
|
||||
userDoctorData["multi_point_status"] = 2
|
||||
userDoctorData["multi_point_fail_reason"] = ""
|
||||
}
|
||||
|
||||
// 处理科室电话
|
||||
if userDoctor.DepartmentCustomMobile != putUserDoctorRequest.DepartmentCustomMobile {
|
||||
userDoctorData["department_custom_id"] = putUserDoctorRequest.DepartmentCustomMobile
|
||||
@@ -310,62 +331,14 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, putUserDoctorRequest r
|
||||
return false, errors.New("未上传新的签名图片")
|
||||
}
|
||||
if putUserDoctorRequest.SignImage != "" {
|
||||
signImage := strings.Replace(putUserDoctorRequest.SignImage, "https://img.applets.igandanyiyuan.com", "", 1)
|
||||
signImage := utils.RemoveOssDomain(putUserDoctorRequest.SignImage)
|
||||
if signImage != userDoctorInfo.SignImage {
|
||||
if userDoctor.MultiPointStatus == 2 {
|
||||
return false, errors.New("多点执业审核中,请操作后进行修改")
|
||||
}
|
||||
|
||||
userDoctorInfoData["sign_image"] = signImage
|
||||
}
|
||||
}
|
||||
|
||||
// 处理专长
|
||||
if len(putUserDoctorRequest.DoctorExpertise) > 0 {
|
||||
// 检测专长是否存在
|
||||
diseaseClassExpertiseDao := dao.DiseaseClassExpertiseDao{}
|
||||
for _, v := range putUserDoctorRequest.DoctorExpertise {
|
||||
expertiseId, err := strconv.ParseInt(v, 10, 64)
|
||||
if err != nil {
|
||||
return false, errors.New("专长错误")
|
||||
}
|
||||
|
||||
diseaseClassExpertise, err := diseaseClassExpertiseDao.GetDiseaseClassExpertiseById(expertiseId)
|
||||
if err != nil || diseaseClassExpertise == nil {
|
||||
return false, errors.New("专长数据错误")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理多点问题
|
||||
fieldsToCheck := []string{"id_card_front", "id_card_back", "sign_image"}
|
||||
|
||||
exists := false
|
||||
for _, field := range fieldsToCheck {
|
||||
if _, ok := userDoctorInfoData[field]; ok {
|
||||
exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if exists {
|
||||
idCardFront := userDoctorInfo.IdCardFront
|
||||
idCardBack := userDoctorInfo.IdCardBack
|
||||
signImage := userDoctorInfo.SignImage
|
||||
|
||||
if _, ok := userDoctorInfoData["id_card_front"]; ok {
|
||||
idCardFront = userDoctorInfoData["id_card_front"].(string)
|
||||
}
|
||||
|
||||
if _, ok := userDoctorInfoData["id_card_back"]; ok {
|
||||
idCardBack = userDoctorInfoData["id_card_back"].(string)
|
||||
}
|
||||
|
||||
if _, ok := userDoctorInfoData["sign_image"]; ok {
|
||||
signImage = userDoctorInfoData["sign_image"].(string)
|
||||
}
|
||||
|
||||
if idCardFront != "" && idCardBack != "" && signImage != "" {
|
||||
// 检测是否存在正在审核中的处方
|
||||
orderPrescriptionDao := dao.OrderPrescriptionDao{}
|
||||
|
||||
@@ -387,6 +360,23 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, putUserDoctorRequest r
|
||||
}
|
||||
}
|
||||
|
||||
// 处理专长
|
||||
if len(putUserDoctorRequest.DoctorExpertise) > 0 {
|
||||
// 检测专长是否存在
|
||||
diseaseClassExpertiseDao := dao.DiseaseClassExpertiseDao{}
|
||||
for _, v := range putUserDoctorRequest.DoctorExpertise {
|
||||
expertiseId, err := strconv.ParseInt(v, 10, 64)
|
||||
if err != nil {
|
||||
return false, errors.New("专长错误")
|
||||
}
|
||||
|
||||
diseaseClassExpertise, err := diseaseClassExpertiseDao.GetDiseaseClassExpertiseById(expertiseId)
|
||||
if err != nil || diseaseClassExpertise == nil {
|
||||
return false, errors.New("专长数据错误")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 开始事务
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
@@ -482,108 +472,47 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, putUserDoctorRequest r
|
||||
}
|
||||
}
|
||||
|
||||
// 判断科室是否修改,同步修改ca平台
|
||||
if userDoctor.DepartmentCustomId != departmentCustomId {
|
||||
// 获取科室数据
|
||||
hospitalDepartmentCustomDao := dao.HospitalDepartmentCustom{}
|
||||
hospitalDepartmentCustom, err := hospitalDepartmentCustomDao.GetHospitalDepartmentCustomById(departmentCustomId)
|
||||
if err != nil || hospitalDepartmentCustom == nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("科室错误")
|
||||
}
|
||||
|
||||
// 获取云证书数据
|
||||
userCaCertDao := dao.UserCaCert{}
|
||||
userCaCerts, err := userCaCertDao.GetUserCaCertListByUserId(userDoctor.UserId)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("修改失败")
|
||||
}
|
||||
|
||||
if userCaCerts != nil && len(userCaCerts) > 0 {
|
||||
// 修改云证书
|
||||
editCloudCertRequestData := &ca.EditCloudCertRequestData{
|
||||
EntityId: strconv.FormatInt(userDoctor.UserId, 10),
|
||||
EntityType: "Personal",
|
||||
PersonalPhone: user.Mobile,
|
||||
PersonalName: userDoctorInfo.CardName,
|
||||
PersonalIdNumber: userDoctorInfo.CardNum,
|
||||
OrgName: "",
|
||||
OrgNumber: "",
|
||||
Pin: strconv.FormatInt(userDoctor.UserId, 10),
|
||||
OrgDept: hospitalDepartmentCustom.DepartmentName, // // 卫生证书:医院部门
|
||||
Province: "四川省",
|
||||
Locality: "成都市",
|
||||
AuthType: "实人认证",
|
||||
// AuthTime: strconv.FormatInt(time.Now().Unix(), 10),
|
||||
AuthTime: "1688694270",
|
||||
AuthResult: "认证通过",
|
||||
AuthNoticeType: "数字证书变更告知",
|
||||
}
|
||||
|
||||
editCloudCertResponse, err := ca.EditCloudCert(editCloudCertRequestData)
|
||||
if err != nil || editCloudCertResponse == nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 修改ca监管证书表
|
||||
// 处理签名图片-如果更改,查看是否已添加签章配置,会进行删除
|
||||
if putUserDoctorRequest.SignImage != "" {
|
||||
signImage := utils.RemoveOssDomain(putUserDoctorRequest.SignImage)
|
||||
if signImage != userDoctorInfo.SignImage {
|
||||
// 检测是否存在云证书
|
||||
userCaCertDao := dao.UserCaCert{}
|
||||
data := make(map[string]interface{})
|
||||
data["cert_base64"] = editCloudCertResponse.CertBase64
|
||||
data["cert_chain_p7"] = editCloudCertResponse.CertP7
|
||||
data["cert_serial_number"] = editCloudCertResponse.CertP7
|
||||
err = userCaCertDao.EditUserCaCertById(tx, userCaCerts[0].CertId, data)
|
||||
userCaCerts, err := userCaCertDao.GetUserCaCertListByUserId(userDoctor.UserId)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("删除失败")
|
||||
return false, errors.New("修改失败")
|
||||
}
|
||||
|
||||
if userCaCerts != nil && len(userCaCerts) > 0 {
|
||||
userCaCert := userCaCerts[0]
|
||||
// 检测是否已经添加签章配置
|
||||
if userCaCert.IsSignConfig == 1 {
|
||||
// 修改签章配置为未添加
|
||||
data := make(map[string]interface{})
|
||||
data["is_sign_config"] = 0
|
||||
err = userCaCertDao.EditUserCaCertById(tx, userCaCert.CertId, data)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 删除签章配置
|
||||
deleteUserSignConfigRequestData := &ca.DeleteUserSignConfigRequestData{
|
||||
UserId: strconv.FormatInt(userDoctor.UserId, 10),
|
||||
ConfigKey: strconv.FormatInt(userDoctor.UserId, 10),
|
||||
}
|
||||
|
||||
_, err := ca.DeleteUserSignConfig(deleteUserSignConfigRequestData)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 判断签名图片是否修改,同步修改ca平台
|
||||
// 1、新用户,未存在证书
|
||||
// if putUserDoctorRequest.SignImage != "" {
|
||||
// signImage := strings.Replace(putUserDoctorRequest.SignImage, "https://img.applets.igandanyiyuan.com", "", 1)
|
||||
// if signImage != userDoctorInfo.SignImage {
|
||||
// // 检测是否存在云证书
|
||||
// userCaCertDao := dao.UserCaCert{}
|
||||
// userCaCerts, err := userCaCertDao.GetUserCaCertListByUserId(userDoctor.UserId)
|
||||
// if err != nil {
|
||||
// tx.Rollback()
|
||||
// return false, errors.New("修改失败")
|
||||
// }
|
||||
//
|
||||
// if userCaCerts != nil && len(userCaCerts) > 0 {
|
||||
// userCaCert := userCaCerts[0]
|
||||
// // 检测是否已经添加签章配置
|
||||
// if userCaCert.IsSignConfig == 1 {
|
||||
// // 修改签章配置为未添加
|
||||
// data := make(map[string]interface{})
|
||||
// data["is_sign_config"] = 0
|
||||
// err = userCaCertDao.EditUserCaCertById(tx, userCaCert.CertId, data)
|
||||
// if err != nil {
|
||||
// tx.Rollback()
|
||||
// return false, errors.New(err.Error())
|
||||
// }
|
||||
//
|
||||
// // 删除签章配置
|
||||
// deleteUserSignConfigRequestData := &ca.DeleteUserSignConfigRequestData{
|
||||
// UserId: strconv.FormatInt(userDoctor.UserId, 10),
|
||||
// ConfigKey: strconv.FormatInt(userDoctor.UserId, 10),
|
||||
// }
|
||||
//
|
||||
// _, err := ca.DeleteUserSignConfig(deleteUserSignConfigRequestData)
|
||||
// if err != nil {
|
||||
// tx.Rollback()
|
||||
// return false, errors.New(err.Error())
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
@@ -723,7 +652,7 @@ func (r *UserDoctorService) AddUserDoctor(userId string, a requests.AddUserDocto
|
||||
|
||||
// 多点执业状态
|
||||
var multiPointStatus int
|
||||
if a.IdCardFront != "" && a.IdCardBack != "" && a.SignImage != "" {
|
||||
if a.IdCardFront != "" && a.IdCardBack != "" && a.SignImage != "" && departmentCustomId != 0 {
|
||||
multiPointStatus = 2
|
||||
}
|
||||
|
||||
@@ -1257,14 +1186,6 @@ func (r *UserDoctorService) GetMulti(doctorId int64) (g *userDoctorResponse.GetM
|
||||
return nil, errors.New("用户数据错误")
|
||||
}
|
||||
|
||||
userDoctorService := UserDoctorService{}
|
||||
|
||||
// 获取医生专长
|
||||
doctorExpertise, err := userDoctorService.GetUserDoctorExpertiseByDoctorId(doctorId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
var userDoctorInfo *userDoctorInfoResponse.UserDoctorInfo
|
||||
if userDoctor.UserDoctorInfo != nil {
|
||||
@@ -1305,8 +1226,181 @@ func (r *UserDoctorService) GetMulti(doctorId int64) (g *userDoctorResponse.GetM
|
||||
User: user,
|
||||
Hospital: hospital,
|
||||
UserDoctorInfo: userDoctorInfo,
|
||||
DoctorExpertise: doctorExpertise, // 专长
|
||||
}
|
||||
|
||||
return g, nil
|
||||
}
|
||||
|
||||
// PutMulti 多点-审核医生
|
||||
func (r *UserDoctorService) PutMulti(doctorId int64, req requests.PutMulti) (bool, error) {
|
||||
// 获取医生数据
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, err := userDoctorDao.GetUserDoctorById(doctorId)
|
||||
if err != nil || userDoctor == nil {
|
||||
return false, errors.New("医生数据错误")
|
||||
}
|
||||
|
||||
// 获取医生详情数据
|
||||
userDoctorInfoDao := dao.UserDoctorInfoDao{}
|
||||
userDoctorInfo, err := userDoctorInfoDao.GetUserDoctorInfoByDoctorId(doctorId)
|
||||
if err != nil {
|
||||
return false, errors.New("医生详情数据错误")
|
||||
}
|
||||
|
||||
// 获取用户数据
|
||||
userDao := dao.UserDao{}
|
||||
user, err := userDao.GetUserById(userDoctor.UserId)
|
||||
if err != nil || user == nil {
|
||||
return false, errors.New("医生数据错误")
|
||||
}
|
||||
|
||||
if userDoctor.MultiPointStatus == 1 {
|
||||
return false, errors.New("已审核成功,无法进行操作")
|
||||
}
|
||||
|
||||
userDoctorData := make(map[string]interface{}) // 医生数据
|
||||
|
||||
if userDoctor.IdenAuthStatus == req.MultiPointStatus {
|
||||
return false, errors.New("请勿重复操作")
|
||||
}
|
||||
|
||||
// 开始事务
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
// 检测是否存在云证书
|
||||
userCaCertDao := dao.UserCaCert{}
|
||||
userCaCerts, err := userCaCertDao.GetUserCaCertListByUserId(userDoctor.UserId)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("修改失败")
|
||||
}
|
||||
|
||||
// 获取自定义科室数据
|
||||
hospitalDepartmentCustomDao := dao.HospitalDepartmentCustom{}
|
||||
hospitalDepartmentCustom, err := hospitalDepartmentCustomDao.GetHospitalDepartmentCustomById(userDoctor.DepartmentCustomId)
|
||||
if err != nil || hospitalDepartmentCustom == nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("科室错误")
|
||||
}
|
||||
|
||||
// 获取标准科室数据
|
||||
hospitalDepartmentDao := dao.HospitalDepartment{}
|
||||
hospitalDepartment, err := hospitalDepartmentDao.GetHospitalDepartmentById(hospitalDepartmentCustom.DepartmentId)
|
||||
if err != nil || hospitalDepartment == nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("科室错误")
|
||||
}
|
||||
|
||||
if userCaCerts == nil && len(userCaCerts) == 0 {
|
||||
// 申请云证书
|
||||
cloudCertRequestData := &ca.AddCloudCertRequest{
|
||||
EntityId: strconv.FormatInt(userDoctor.UserId, 10),
|
||||
EntityType: "Personal",
|
||||
PersonalPhone: user.Mobile,
|
||||
PersonalName: userDoctorInfo.CardName,
|
||||
PersonalIdNumber: userDoctorInfo.CardNum,
|
||||
OrgName: "",
|
||||
OrgNumber: "",
|
||||
Pin: strconv.FormatInt(userDoctor.UserId, 10),
|
||||
OrgDept: hospitalDepartment.DepartmentName, // // 卫生证书:医院部门
|
||||
Province: "四川省",
|
||||
Locality: "成都市",
|
||||
AuthType: "实人认证",
|
||||
AuthTime: strconv.FormatInt(time.Now().Unix(), 10),
|
||||
AuthResult: "认证通过",
|
||||
AuthNoticeType: "数字证书申请告知",
|
||||
}
|
||||
|
||||
cloudCertResponse, err := ca.AddCloudCert(cloudCertRequestData)
|
||||
if err != nil || cloudCertResponse == nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 新增ca监管证书表
|
||||
userCaCert := &model.UserCaCert{
|
||||
UserId: &userDoctor.UserId,
|
||||
IsSystem: 0,
|
||||
Type: 1,
|
||||
CertBase64: cloudCertResponse.CertBase64,
|
||||
CertChainP7: cloudCertResponse.CertP7,
|
||||
CertSerialNumber: cloudCertResponse.CertSerialnumber,
|
||||
CaPin: strconv.FormatInt(userDoctor.UserId, 10),
|
||||
IsSignConfig: 0,
|
||||
SignConfig: "",
|
||||
}
|
||||
|
||||
userCaCert, err = userCaCertDao.AddUserCaCert(tx, userCaCert)
|
||||
if err != nil || userCaCert == nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
} else {
|
||||
// 修改云证书
|
||||
cloudCertRequestData := &ca.EditCloudCertRequestData{
|
||||
EntityId: strconv.FormatInt(userDoctor.UserId, 10),
|
||||
EntityType: "Personal",
|
||||
PersonalPhone: user.Mobile,
|
||||
PersonalName: userDoctorInfo.CardName,
|
||||
PersonalIdNumber: userDoctorInfo.CardNum,
|
||||
OrgName: "",
|
||||
OrgNumber: "",
|
||||
Pin: strconv.FormatInt(userDoctor.UserId, 10),
|
||||
OrgDept: hospitalDepartment.DepartmentName, // // 卫生证书:医院部门
|
||||
Province: "四川省",
|
||||
Locality: "成都市",
|
||||
AuthType: "实人认证",
|
||||
AuthTime: strconv.FormatInt(time.Now().Unix(), 10),
|
||||
AuthResult: "认证通过",
|
||||
AuthNoticeType: "数字证书变更告知",
|
||||
}
|
||||
|
||||
cloudCertResponse, err := ca.EditCloudCert(cloudCertRequestData)
|
||||
if err != nil || cloudCertResponse == nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 修改ca监管证书表
|
||||
userCaCertDao := dao.UserCaCert{}
|
||||
data := make(map[string]interface{})
|
||||
data["cert_base64"] = cloudCertResponse.CertBase64
|
||||
data["cert_chain_p7"] = cloudCertResponse.CertP7
|
||||
data["cert_serial_number"] = cloudCertResponse.CertSerialnumber
|
||||
err = userCaCertDao.EditUserCaCertById(tx, userCaCerts[0].CertId, data)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("审核失败")
|
||||
}
|
||||
}
|
||||
|
||||
userDoctorData["multi_point_time"] = time.Now().Format("2006-01-02 15:04:05")
|
||||
|
||||
// 审核不通过
|
||||
if req.MultiPointStatus == 3 {
|
||||
userDoctorData["multi_point_status"] = 3
|
||||
userDoctorData["multi_point_fail_reason"] = req.MultiPointFailReason
|
||||
}
|
||||
|
||||
// 审核通过
|
||||
if req.MultiPointStatus == 1 {
|
||||
userDoctorData["multi_point_status"] = 1
|
||||
userDoctorData["multi_point_fail_reason"] = ""
|
||||
|
||||
}
|
||||
|
||||
// 修改医生数据
|
||||
err = userDoctorDao.EditUserDoctorById(tx, doctorId, userDoctorData)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("审核失败")
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user