新增简介审核-医生详情、简介审核-审核医生
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/config"
|
||||
"hospital-admin-api/extend/aliyun"
|
||||
"hospital-admin-api/extend/ca"
|
||||
"hospital-admin-api/extend/tencentIm"
|
||||
"hospital-admin-api/extend/verifyDun"
|
||||
@@ -1210,6 +1211,8 @@ func (r *UserDoctorService) PutUserDoctorPending(doctorId int64, req requests.Pu
|
||||
|
||||
userDoctorData["iden_auth_status"] = 1
|
||||
userDoctorInfoData["qualification_cert_num"] = req.QualificationCertNum
|
||||
userDoctorData["introduction_status"] = 1
|
||||
userDoctorData["introduction_time"] = time.Now().Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
// 开始事务
|
||||
@@ -1600,3 +1603,254 @@ func (r *UserDoctorService) GetDoctorEstimateIncome(doctorId int64) (g float64,
|
||||
result, _ := estimateIncome.Float64()
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetUserDoctorIntroduction 简介审核-医生详情
|
||||
func (r *UserDoctorService) GetUserDoctorIntroduction(doctorId int64) (g *dto.UserDoctorIntroductionDto, err error) {
|
||||
// 获取医生数据
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, err := userDoctorDao.GetUserDoctorPreloadById(doctorId)
|
||||
if err != nil || userDoctor == nil {
|
||||
return nil, errors.New("用户数据错误")
|
||||
}
|
||||
|
||||
if userDoctor.IntroductionStatus != 2 {
|
||||
return nil, errors.New("非审核数据")
|
||||
}
|
||||
|
||||
// 获取简介审核数据
|
||||
doctorIntroductionRecordDao := dao.DoctorIntroductionRecordDao{}
|
||||
doctorIntroductionRecord, err := doctorIntroductionRecordDao.GetDoctorIntroductionRecordByDoctorId(userDoctor.DoctorId)
|
||||
if err != nil || doctorIntroductionRecord == nil {
|
||||
return nil, errors.New("用户数据错误")
|
||||
}
|
||||
|
||||
// 处理医生专长
|
||||
var expertiseIds []string
|
||||
if doctorIntroductionRecord.ExpertiseIds != "" {
|
||||
expertiseIds = strings.Split(doctorIntroductionRecord.ExpertiseIds, ",")
|
||||
} else {
|
||||
// 获取医生专长
|
||||
userDoctorService := UserDoctorService{}
|
||||
doctorExpertise, err := userDoctorService.GetUserDoctorExpertiseByDoctorId(doctorId)
|
||||
if err != nil {
|
||||
return nil, errors.New("用户数据错误")
|
||||
}
|
||||
|
||||
for _, expertise := range doctorExpertise {
|
||||
expertiseIds = append(expertiseIds, expertise.ExpertiseId)
|
||||
}
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
g = dto.GetUserDoctorIntroductionDto(userDoctor)
|
||||
|
||||
if doctorIntroductionRecord.Avatar != "" {
|
||||
g.Avatar = utils.AddOssDomain(doctorIntroductionRecord.Avatar)
|
||||
}
|
||||
|
||||
if doctorIntroductionRecord.BeGoodAt != "" {
|
||||
g.BeGoodAt = doctorIntroductionRecord.BeGoodAt
|
||||
}
|
||||
|
||||
if doctorIntroductionRecord.BriefIntroduction != "" {
|
||||
g.BriefIntroduction = doctorIntroductionRecord.BriefIntroduction
|
||||
}
|
||||
|
||||
// 加载用户
|
||||
g.LoadUser(userDoctor.User)
|
||||
|
||||
// 加载医院
|
||||
g.LoadHospital(userDoctor.Hospital)
|
||||
|
||||
// 加载医生专长
|
||||
g.DoctorExpertise = expertiseIds
|
||||
|
||||
// 加载医生详情
|
||||
g.LoadUserDoctorInfo(userDoctor.UserDoctorInfo)
|
||||
|
||||
return g, nil
|
||||
}
|
||||
|
||||
// PutDoctorIntroduction 简介审核-审核医生
|
||||
func (r *UserDoctorService) PutDoctorIntroduction(doctorId int64, req requests.PutDoctorIntroduction) (bool, error) {
|
||||
// 获取医生数据
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, err := userDoctorDao.GetUserDoctorById(doctorId)
|
||||
if err != nil || userDoctor == nil {
|
||||
return false, errors.New("医生数据错误")
|
||||
}
|
||||
|
||||
if userDoctor.IntroductionStatus == req.IntroductionStatus {
|
||||
return false, errors.New("请勿重复操作")
|
||||
}
|
||||
|
||||
if userDoctor.IntroductionStatus == 1 {
|
||||
return false, errors.New("已审核成功,无法进行操作")
|
||||
}
|
||||
|
||||
if userDoctor.IdenAuthStatus != 1 {
|
||||
return false, errors.New("请先完成身份认证")
|
||||
}
|
||||
|
||||
// 获取用户数据
|
||||
userDao := dao.UserDao{}
|
||||
user, err := userDao.GetUserById(userDoctor.UserId)
|
||||
if err != nil || user == nil {
|
||||
return false, errors.New("医生数据错误")
|
||||
}
|
||||
|
||||
// 获取简介审核数据
|
||||
doctorIntroductionRecordDao := dao.DoctorIntroductionRecordDao{}
|
||||
doctorIntroductionRecord, err := doctorIntroductionRecordDao.GetDoctorIntroductionRecordByDoctorId(userDoctor.DoctorId)
|
||||
if err != nil || doctorIntroductionRecord == nil {
|
||||
return false, errors.New("审核失败")
|
||||
}
|
||||
|
||||
// 开始事务
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
// 修改医生数据-审核状态
|
||||
userDoctorData := make(map[string]interface{}) // 医生数据
|
||||
|
||||
doctorIdenFailDao := dao.DoctorIdenFailDao{}
|
||||
|
||||
// 审核不通过
|
||||
if req.IntroductionStatus == 3 {
|
||||
if req.AvatarReason != "" {
|
||||
doctorIdenFail := &model.DoctorIdenFail{
|
||||
DoctorId: doctorId,
|
||||
FieldName: "avatar",
|
||||
FailReason: req.AvatarReason,
|
||||
}
|
||||
doctorIdenFail, err = doctorIdenFailDao.AddDoctorIdenFail(tx, doctorIdenFail)
|
||||
if err != nil || doctorIdenFail == nil {
|
||||
tx.Rollback()
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
|
||||
if req.BriefIntroductionReason != "" {
|
||||
doctorIdenFail := &model.DoctorIdenFail{
|
||||
DoctorId: doctorId,
|
||||
FieldName: "brief_introduction",
|
||||
FailReason: req.BriefIntroductionReason,
|
||||
}
|
||||
doctorIdenFail, err = doctorIdenFailDao.AddDoctorIdenFail(tx, doctorIdenFail)
|
||||
if err != nil || doctorIdenFail == nil {
|
||||
tx.Rollback()
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
|
||||
if req.BeGoodAtReason != "" {
|
||||
doctorIdenFail := &model.DoctorIdenFail{
|
||||
DoctorId: doctorId,
|
||||
FieldName: "be_good_at",
|
||||
FailReason: req.BeGoodAtReason,
|
||||
}
|
||||
doctorIdenFail, err = doctorIdenFailDao.AddDoctorIdenFail(tx, doctorIdenFail)
|
||||
if err != nil || doctorIdenFail == nil {
|
||||
tx.Rollback()
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
|
||||
if req.DoctorExpertiseReason != "" {
|
||||
doctorIdenFail := &model.DoctorIdenFail{
|
||||
DoctorId: doctorId,
|
||||
FieldName: "doctor_expertise",
|
||||
FailReason: req.DoctorExpertiseReason,
|
||||
}
|
||||
doctorIdenFail, err = doctorIdenFailDao.AddDoctorIdenFail(tx, doctorIdenFail)
|
||||
if err != nil || doctorIdenFail == nil {
|
||||
tx.Rollback()
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 审核通过
|
||||
if req.IntroductionStatus == 1 {
|
||||
// 审核通过删除所有不通过原因数据
|
||||
maps := make(map[string]interface{})
|
||||
maps["doctor_id"] = doctorId
|
||||
err = doctorIdenFailDao.DeleteDoctorIdenFail(tx, maps)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("审核失败")
|
||||
}
|
||||
|
||||
if doctorIntroductionRecord.BeGoodAt != "" {
|
||||
userDoctorData["be_good_at"] = doctorIntroductionRecord.BeGoodAt
|
||||
}
|
||||
|
||||
if doctorIntroductionRecord.BriefIntroduction != "" {
|
||||
userDoctorData["brief_introduction"] = doctorIntroductionRecord.BriefIntroduction
|
||||
}
|
||||
|
||||
// 更新医生im资料
|
||||
if doctorIntroductionRecord.Avatar != "" {
|
||||
userDoctorData["avatar"] = doctorIntroductionRecord.Avatar
|
||||
|
||||
profileItem := []tencentIm.ProfileItem{
|
||||
{
|
||||
Tag: "Tag_Profile_IM_Image",
|
||||
Value: doctorIntroductionRecord.Avatar,
|
||||
},
|
||||
}
|
||||
|
||||
res, err := tencentIm.SetProfile(strconv.FormatInt(userDoctor.UserId, 10), profileItem)
|
||||
if err != nil || res != true {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// 删除审核记录表
|
||||
maps = make(map[string]interface{})
|
||||
maps["doctor_id"] = doctorId
|
||||
err = doctorIntroductionRecordDao.DeleteDoctorIntroductionRecord(tx, maps)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("审核失败")
|
||||
}
|
||||
}
|
||||
|
||||
// 更新医生表数据
|
||||
userDoctorData["introduction_status"] = req.IntroductionStatus
|
||||
userDoctorData["introduction_time"] = time.Now().Format("2006-01-02 15:04:05")
|
||||
err = userDoctorDao.EditUserDoctorById(tx, doctorId, userDoctorData)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("审核失败")
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
||||
if config.C.Env == "prod" {
|
||||
// 发送短信-医生修改简介审核通过
|
||||
if req.IntroductionStatus == 1 {
|
||||
templateParam := make(map[string]interface{})
|
||||
err := aliyun.SendSms(user.Mobile, "SMS_271990126", "医生修改简介审核通过", templateParam)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
|
||||
// 发送短信-医生修改简介审核拒绝
|
||||
if req.IntroductionStatus == 3 {
|
||||
templateParam := make(map[string]interface{})
|
||||
err := aliyun.SendSms(user.Mobile, "SMS_271990126", "医生修改简介审核拒绝", templateParam)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user