新增医生问诊配置
This commit is contained in:
+205
-41
@@ -187,15 +187,15 @@ func (r *DoctorInquiryConfigService) PutDoctorInquiryConfig(inquiryConfigId int6
|
||||
|
||||
// 判断医生数据
|
||||
if userDoctor.IdcardStatus != 1 {
|
||||
return false, errors.New("请先进行实名认证")
|
||||
return false, errors.New("该医生未进行实名认证")
|
||||
}
|
||||
|
||||
if userDoctor.IdenAuthStatus != 1 {
|
||||
return false, errors.New("请先进行身份认证")
|
||||
return false, errors.New("该医生未进行身份认证")
|
||||
}
|
||||
|
||||
if userDoctor.IsBindBank != 1 {
|
||||
return false, errors.New("请先进行绑定结算银行卡")
|
||||
return false, errors.New("该医生未进行绑定结算银行卡")
|
||||
}
|
||||
|
||||
// 获取系统问诊配置
|
||||
@@ -239,7 +239,7 @@ func (r *DoctorInquiryConfigService) PutDoctorInquiryConfig(inquiryConfigId int6
|
||||
|
||||
// 验证医生坐班时间
|
||||
if doctorInquiryConfig.InquiryType == 2 || doctorInquiryConfig.InquiryType == 4 {
|
||||
if userDoctor.IsPlatformDeepCooperation == 1 && len(req.PutDoctorInquiryTime) <= 0 {
|
||||
if userDoctor.IsPlatformDeepCooperation == 1 && len(req.DoctorInquiryTime) <= 0 {
|
||||
return false, errors.New("请填写坐班时间")
|
||||
}
|
||||
}
|
||||
@@ -278,52 +278,216 @@ func (r *DoctorInquiryConfigService) PutDoctorInquiryConfig(inquiryConfigId int6
|
||||
}
|
||||
|
||||
// 处理医生问诊时间
|
||||
if userDoctor.IsPlatformDeepCooperation == 1 && len(req.PutDoctorInquiryTime) > 0 {
|
||||
// 获取医生问诊时间-获取一条即可,用以区分添加/删除
|
||||
doctorInquiryTimeDao := dao.DoctorInquiryTimeDao{}
|
||||
if req.InquiryType == 2 || req.InquiryType == 4 {
|
||||
if userDoctor.IsPlatformDeepCooperation == 1 && len(req.DoctorInquiryTime) > 0 {
|
||||
// 获取医生问诊时间-获取一条即可,用以区分添加/删除
|
||||
doctorInquiryTimeDao := dao.DoctorInquiryTimeDao{}
|
||||
|
||||
maps = make(map[string]interface{})
|
||||
maps["doctor_id"] = doctorInquiryConfig.DoctorId
|
||||
maps["inquiry_type"] = doctorInquiryConfig.InquiryType
|
||||
maps["inquiry_mode"] = doctorInquiryConfig.InquiryMode
|
||||
doctorInquiryTime, _ := doctorInquiryTimeDao.GetDoctorInquiryTime(maps)
|
||||
if doctorInquiryTime != nil {
|
||||
// 删除医生全部问诊时间
|
||||
maps = make(map[string]interface{})
|
||||
maps["doctor_id"] = doctorInquiryConfig.DoctorId
|
||||
maps["inquiry_type"] = doctorInquiryConfig.InquiryType
|
||||
maps["inquiry_mode"] = doctorInquiryConfig.InquiryMode
|
||||
err = doctorInquiryTimeDao.DeleteDoctorInquiryTime(tx, maps)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// 添加医生问诊时间
|
||||
for _, v := range req.PutDoctorInquiryTime {
|
||||
inquiryDate, err := time.Parse("2006-01-02", v.InquiryDate)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
doctorInquiryTime, _ := doctorInquiryTimeDao.GetDoctorInquiryTime(maps)
|
||||
if doctorInquiryTime != nil {
|
||||
// 删除医生全部问诊时间
|
||||
maps = make(map[string]interface{})
|
||||
maps["doctor_id"] = doctorInquiryConfig.DoctorId
|
||||
maps["inquiry_type"] = doctorInquiryConfig.InquiryType
|
||||
maps["inquiry_mode"] = doctorInquiryConfig.InquiryMode
|
||||
err = doctorInquiryTimeDao.DeleteDoctorInquiryTime(tx, maps)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
startTime := strings.Replace(v.StartTime, ":", "", -1)
|
||||
endTime := strings.Replace(v.EndTime, ":", "", -1)
|
||||
// 添加医生问诊时间
|
||||
for _, v := range req.DoctorInquiryTime {
|
||||
inquiryDate, err := time.Parse("2006-01-02", v.InquiryDate)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
|
||||
doctorInquiryTime = &model.DoctorInquiryTime{
|
||||
DoctorId: userDoctor.DoctorId,
|
||||
InquiryType: req.InquiryType,
|
||||
InquiryMode: req.InquiryMode,
|
||||
InquiryDate: model.LocalTime(inquiryDate),
|
||||
StartTime: startTime,
|
||||
EndTime: endTime,
|
||||
}
|
||||
startTime := strings.Replace(v.StartTime, ":", "", -1)
|
||||
endTime := strings.Replace(v.EndTime, ":", "", -1)
|
||||
|
||||
doctorInquiryTime, err = doctorInquiryTimeDao.AddDoctorInquiryTime(tx, doctorInquiryTime)
|
||||
if err != nil || doctorInquiryTime == nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
doctorInquiryTime = &model.DoctorInquiryTime{
|
||||
DoctorId: userDoctor.DoctorId,
|
||||
InquiryType: req.InquiryType,
|
||||
InquiryMode: req.InquiryMode,
|
||||
InquiryDate: model.LocalTime(inquiryDate),
|
||||
StartTime: startTime,
|
||||
EndTime: endTime,
|
||||
}
|
||||
|
||||
doctorInquiryTime, err = doctorInquiryTimeDao.AddDoctorInquiryTime(tx, doctorInquiryTime)
|
||||
if err != nil || doctorInquiryTime == nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// AddDoctorInquiryConfig 新增医生问诊配置
|
||||
func (r *DoctorInquiryConfigService) AddDoctorInquiryConfig(req requests.AddDoctorInquiryConfig) (bool, error) {
|
||||
doctorInquiryConfigDao := dao.DoctorInquiryConfigDao{}
|
||||
|
||||
// 获取医生问诊配置
|
||||
maps := make(map[string]interface{})
|
||||
maps["doctor_id"] = req.DoctorId
|
||||
maps["inquiry_type"] = req.InquiryType
|
||||
maps["inquiry_mode"] = req.InquiryMode
|
||||
doctorInquiryConfig, err := doctorInquiryConfigDao.GetDoctorInquiryConfig(maps)
|
||||
if doctorInquiryConfig != nil {
|
||||
return false, errors.New("该医生已存在此类型问诊配置")
|
||||
}
|
||||
|
||||
// 获取医生数据
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, err := userDoctorDao.GetUserDoctorById(req.DoctorId)
|
||||
if err != nil || userDoctor == nil {
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 判断医生数据
|
||||
if userDoctor.IdcardStatus != 1 {
|
||||
return false, errors.New("该医生未进行实名认证")
|
||||
}
|
||||
|
||||
if userDoctor.IdenAuthStatus != 1 {
|
||||
return false, errors.New("该医生未进行身份认证")
|
||||
}
|
||||
|
||||
if userDoctor.IsBindBank != 1 {
|
||||
return false, errors.New("该医生未进行绑定结算银行卡")
|
||||
}
|
||||
|
||||
// 获取系统问诊配置
|
||||
systemInquiryConfigDao := dao.SystemInquiryConfigDao{}
|
||||
|
||||
maps = make(map[string]interface{})
|
||||
maps["inquiry_type"] = req.InquiryType
|
||||
maps["inquiry_mode"] = req.InquiryMode
|
||||
systemInquiryConfig, err := systemInquiryConfigDao.GetSystemInquiryConfig(maps)
|
||||
if err != nil || systemInquiryConfig == nil {
|
||||
return false, errors.New("系统问诊配置错误")
|
||||
}
|
||||
|
||||
// 验证问诊数量
|
||||
if req.WorkNumDay > systemInquiryConfig.MaxWorkNumDay {
|
||||
return false, errors.New("超出每日最大接诊数量")
|
||||
}
|
||||
|
||||
// 验证问诊价格-在线问诊
|
||||
if req.InquiryType == 1 {
|
||||
if req.InquiryPrice > systemInquiryConfig.MaxInquiryPrice || req.InquiryPrice < systemInquiryConfig.MinInquiryPrice {
|
||||
return false, errors.New("问诊价格填写错误")
|
||||
}
|
||||
}
|
||||
|
||||
// 验证问诊价格-快速问诊/问诊购药
|
||||
if req.InquiryType == 2 || req.InquiryType == 4 {
|
||||
inquiryPrice := strconv.FormatFloat(req.InquiryPrice, 'f', -1, 64)
|
||||
if inquiryPrice != systemInquiryConfig.InquiryPrice {
|
||||
return false, errors.New("问诊价格填写错误")
|
||||
}
|
||||
}
|
||||
|
||||
// 验证问诊价格-公益问诊
|
||||
if req.InquiryType == 3 {
|
||||
inquiryPrice := strconv.FormatFloat(req.InquiryPrice, 'f', -1, 64)
|
||||
if !strings.Contains(systemInquiryConfig.InquiryPrice, inquiryPrice) {
|
||||
return false, errors.New("问诊价格填写错误")
|
||||
}
|
||||
}
|
||||
|
||||
// 验证医生坐班时间
|
||||
if req.InquiryType == 2 || req.InquiryType == 4 {
|
||||
if userDoctor.IsPlatformDeepCooperation == 1 && len(req.DoctorInquiryTime) <= 0 {
|
||||
return false, errors.New("请填写坐班时间")
|
||||
}
|
||||
}
|
||||
|
||||
// 开始事务
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
// 新增医生问诊配置
|
||||
doctorInquiryConfig = &model.DoctorInquiryConfig{
|
||||
DoctorId: req.DoctorId,
|
||||
InquiryType: req.InquiryType,
|
||||
InquiryMode: req.InquiryMode,
|
||||
IsEnable: req.IsEnable,
|
||||
LastEnableMethod: 2,
|
||||
WorkNumDay: req.WorkNumDay,
|
||||
InquiryPrice: req.InquiryPrice,
|
||||
}
|
||||
|
||||
doctorInquiryConfig, err = doctorInquiryConfigDao.AddDoctorInquiryConfig(tx, doctorInquiryConfig)
|
||||
if err != nil || doctorInquiryConfig == nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 处理医生问诊时间
|
||||
if req.InquiryType == 2 || req.InquiryType == 4 {
|
||||
if userDoctor.IsPlatformDeepCooperation == 1 && len(req.DoctorInquiryTime) > 0 {
|
||||
// 获取医生问诊时间-获取一条即可,用以区分添加/删除
|
||||
doctorInquiryTimeDao := dao.DoctorInquiryTimeDao{}
|
||||
|
||||
maps = make(map[string]interface{})
|
||||
maps["doctor_id"] = doctorInquiryConfig.DoctorId
|
||||
maps["inquiry_type"] = doctorInquiryConfig.InquiryType
|
||||
maps["inquiry_mode"] = doctorInquiryConfig.InquiryMode
|
||||
doctorInquiryTime, _ := doctorInquiryTimeDao.GetDoctorInquiryTime(maps)
|
||||
if doctorInquiryTime != nil {
|
||||
// 删除医生全部问诊时间
|
||||
maps = make(map[string]interface{})
|
||||
maps["doctor_id"] = doctorInquiryConfig.DoctorId
|
||||
maps["inquiry_type"] = doctorInquiryConfig.InquiryType
|
||||
maps["inquiry_mode"] = doctorInquiryConfig.InquiryMode
|
||||
err = doctorInquiryTimeDao.DeleteDoctorInquiryTime(tx, maps)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// 添加医生问诊时间
|
||||
for _, v := range req.DoctorInquiryTime {
|
||||
inquiryDate, err := time.Parse("2006-01-02", v.InquiryDate)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
|
||||
startTime := strings.Replace(v.StartTime, ":", "", -1)
|
||||
endTime := strings.Replace(v.EndTime, ":", "", -1)
|
||||
|
||||
doctorInquiryTime = &model.DoctorInquiryTime{
|
||||
DoctorId: userDoctor.DoctorId,
|
||||
InquiryType: req.InquiryType,
|
||||
InquiryMode: req.InquiryMode,
|
||||
InquiryDate: model.LocalTime(inquiryDate),
|
||||
StartTime: startTime,
|
||||
EndTime: endTime,
|
||||
}
|
||||
|
||||
doctorInquiryTime, err = doctorInquiryTimeDao.AddDoctorInquiryTime(tx, doctorInquiryTime)
|
||||
if err != nil || doctorInquiryTime == nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user