新增处理医生问诊配置方法,后台多点审核医生时,增加医生问诊购药配置
This commit is contained in:
parent
a4e563ee92
commit
f686acec98
@ -162,8 +162,8 @@ func (r *OrderInquiry) GetOrderInquiryRecordPage(c *gin.Context) {
|
||||
}
|
||||
|
||||
result := make(map[string]interface{})
|
||||
result["page"] = req.GetOrderInquiryPage.Page
|
||||
result["page_size"] = req.GetOrderInquiryPage.PageSize
|
||||
result["page"] = req.GetOrderInquiryRecordPage.Page
|
||||
result["page_size"] = req.GetOrderInquiryRecordPage.PageSize
|
||||
result["total"] = total
|
||||
result["data"] = GetOrderInquiryPageResponses
|
||||
responses.OkWithData(result, c)
|
||||
|
||||
63
api/dao/doctorInquiryConfig.go
Normal file
63
api/dao/doctorInquiryConfig.go
Normal file
@ -0,0 +1,63 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type DoctorInquiryConfigDao struct {
|
||||
}
|
||||
|
||||
// GetDoctorInquiryConfigListByDoctorId 获取医生问诊配置数据列表-医生id
|
||||
func (r *DoctorInquiryConfigDao) GetDoctorInquiryConfigListByDoctorId(doctorId int64) (m []*model.DoctorInquiryConfig, err error) {
|
||||
err = global.Db.Where("doctor_id = ?", doctorId).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteDoctorInquiryConfig 删除医生问诊配置
|
||||
func (r *DoctorInquiryConfigDao) DeleteDoctorInquiryConfig(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.DoctorInquiryConfig{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditDoctorInquiryConfigById 修改医生问诊配置-问诊配置id
|
||||
func (r *DoctorInquiryConfigDao) EditDoctorInquiryConfigById(tx *gorm.DB, inquiryConfigId int64, data interface{}) error {
|
||||
err := tx.Model(&model.DoctorInquiryConfig{}).Where("inquiry_config_id = ?", inquiryConfigId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetDoctorInquiryConfigList 获取医生问诊配置列表
|
||||
func (r *DoctorInquiryConfigDao) GetDoctorInquiryConfigList(maps interface{}) (m []*model.DoctorInquiryConfig, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddDoctorInquiryConfig 新增医生问诊配置
|
||||
func (r *DoctorInquiryConfigDao) AddDoctorInquiryConfig(tx *gorm.DB, model *model.DoctorInquiryConfig) (*model.DoctorInquiryConfig, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// GetDoctorInquiryConfig 获取医生问诊配置
|
||||
func (r *DoctorInquiryConfigDao) GetDoctorInquiryConfig(maps interface{}) (m *model.DoctorInquiryConfig, err error) {
|
||||
err = global.Db.Where(maps).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
63
api/dao/systemInquiryConfig.go
Normal file
63
api/dao/systemInquiryConfig.go
Normal file
@ -0,0 +1,63 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type SystemInquiryConfigDao struct {
|
||||
}
|
||||
|
||||
// GetSystemInquiryConfigListByDoctorId 获取系统问诊配置数据列表-系统id
|
||||
func (r *SystemInquiryConfigDao) GetSystemInquiryConfigListByDoctorId(systemInquiryConfigId int64) (m *model.SystemInquiryConfig, err error) {
|
||||
err = global.Db.First(&m, systemInquiryConfigId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteSystemInquiryConfig 删除系统问诊配置
|
||||
func (r *SystemInquiryConfigDao) DeleteSystemInquiryConfig(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.SystemInquiryConfig{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditSystemInquiryConfigById 修改系统问诊配置-问诊配置id
|
||||
func (r *SystemInquiryConfigDao) EditSystemInquiryConfigById(tx *gorm.DB, systemInquiryConfigId int64, data interface{}) error {
|
||||
err := tx.Model(&model.SystemInquiryConfig{}).Where("system_inquiry_config_id = ?", systemInquiryConfigId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSystemInquiryConfigList 获取系统问诊配置列表
|
||||
func (r *SystemInquiryConfigDao) GetSystemInquiryConfigList(maps interface{}) (m []*model.SystemInquiryConfig, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddSystemInquiryConfig 新增系统问诊配置
|
||||
func (r *SystemInquiryConfigDao) AddSystemInquiryConfig(tx *gorm.DB, model *model.SystemInquiryConfig) (*model.SystemInquiryConfig, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// GetSystemInquiryConfig 获取系统问诊配置
|
||||
func (r *SystemInquiryConfigDao) GetSystemInquiryConfig(maps interface{}) (m *model.SystemInquiryConfig, err error) {
|
||||
err = global.Db.Where(maps).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
38
api/model/doctorInquiryConfig.go
Normal file
38
api/model/doctorInquiryConfig.go
Normal file
@ -0,0 +1,38 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// DoctorInquiryConfig 医生接诊配置表
|
||||
type DoctorInquiryConfig struct {
|
||||
InquiryConfigId int64 `gorm:"column:inquiry_config_id;type:bigint(19);primary_key;comment:主键id" json:"inquiry_config_id"`
|
||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id" json:"doctor_id"`
|
||||
InquiryType int `gorm:"column:inquiry_type;type:tinyint(1);default:1;comment:接诊类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药);NOT NULL" json:"inquiry_type"`
|
||||
InquiryMode int `gorm:"column:inquiry_mode;type:tinyint(1);default:1;comment:接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员);NOT NULL" json:"inquiry_mode"`
|
||||
IsEnable int `gorm:"column:is_enable;type:tinyint(1);default:0;comment:是否启用(0:否 1:是)" json:"is_enable"`
|
||||
LastEnableMethod int `gorm:"column:last_enable_method;type:tinyint(1);default:1;comment:最后开启方式(1:自己 2:后台)" json:"last_enable_method"`
|
||||
WorkNumDay int `gorm:"column:work_num_day;type:int(10);default:0;comment:每日接诊数量" json:"work_num_day"`
|
||||
InquiryPrice float64 `gorm:"column:inquiry_price;type:decimal(10,2);comment:接诊价格(专家问诊-公益问诊)" json:"inquiry_price"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *DoctorInquiryConfig) TableName() string {
|
||||
return "gdxz_doctor_inquiry_config"
|
||||
}
|
||||
|
||||
func (m *DoctorInquiryConfig) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.InquiryConfigId == 0 {
|
||||
m.InquiryConfigId = global.Snowflake.Generate().Int64()
|
||||
}
|
||||
|
||||
m.CreatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||||
|
||||
m.UpdatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||||
|
||||
return nil
|
||||
}
|
||||
39
api/model/systemInquiryConfig.go
Normal file
39
api/model/systemInquiryConfig.go
Normal file
@ -0,0 +1,39 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// SystemInquiryConfig 系统问诊配置
|
||||
type SystemInquiryConfig struct {
|
||||
SystemInquiryConfigId int64 `gorm:"column:system_inquiry_config_id;type:bigint(19);primary_key;comment:主键id" json:"system_inquiry_config_id"`
|
||||
InquiryType int `gorm:"column:inquiry_type;type:tinyint(1);comment:接诊类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)" json:"inquiry_type"`
|
||||
InquiryMode int `gorm:"column:inquiry_mode;type:tinyint(1);default:1;comment:接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)" json:"inquiry_mode"`
|
||||
MaxWorkNumDay int `gorm:"column:max_work_num_day;type:int(11);default:0;comment:每日最大接诊数量" json:"max_work_num_day"`
|
||||
InquiryPrice string `gorm:"column:inquiry_price;type:varchar(255);comment:接诊价格" json:"inquiry_price"`
|
||||
MinInquiryPrice float64 `gorm:"column:min_inquiry_price;type:decimal(10,2);comment:最低接诊价格(专家问诊)" json:"min_inquiry_price"`
|
||||
MaxInquiryPrice float64 `gorm:"column:max_inquiry_price;type:decimal(10,2);comment:最高接诊价格(专家问诊)" json:"max_inquiry_price"`
|
||||
TimesNumber int `gorm:"column:times_number;type:int(11);default:0;comment:沟通次数(0为不限制次数)" json:"times_number"`
|
||||
Duration int `gorm:"column:duration;type:int(11);default:0;comment:沟通时长(分钟,0为不限制时长)" json:"duration"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *SystemInquiryConfig) TableName() string {
|
||||
return "gdxz_system_inquiry_config"
|
||||
}
|
||||
|
||||
func (m *SystemInquiryConfig) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.SystemInquiryConfigId == 0 {
|
||||
m.SystemInquiryConfigId = global.Snowflake.Generate().Int64()
|
||||
}
|
||||
|
||||
m.CreatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||||
|
||||
m.UpdatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -462,10 +462,10 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
inquiryGroup := adminGroup.Group("/inquiry")
|
||||
{
|
||||
// 问诊配置
|
||||
settingGroup := inquiryGroup.Group("/setting")
|
||||
configGroup := inquiryGroup.Group("/config")
|
||||
{
|
||||
// 医生问诊配置
|
||||
doctorGroup := settingGroup.Group("/doctor")
|
||||
doctorGroup := configGroup.Group("/doctor")
|
||||
{
|
||||
// 获取开启问诊配置医生列表-分页
|
||||
doctorGroup.GET("", api.UserDoctor.GetUserDoctor)
|
||||
@ -481,7 +481,7 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
}
|
||||
|
||||
// 系统问诊配置
|
||||
systemGroup := settingGroup.Group("/system")
|
||||
systemGroup := configGroup.Group("/config")
|
||||
{
|
||||
// 获取系统问诊配置列表-分页
|
||||
systemGroup.GET("", api.UserDoctor.GetUserDoctorPage)
|
||||
|
||||
114
api/service/InquiryConfig.go
Normal file
114
api/service/InquiryConfig.go
Normal file
@ -0,0 +1,114 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/global"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// InquiryConfigService 问诊配置
|
||||
type InquiryConfigService struct {
|
||||
DoctorInquiryConfigService // 医生问诊配置
|
||||
SystemInquiryConfigService // 系统问诊配置
|
||||
}
|
||||
|
||||
// DoctorInquiryConfigService 医生问诊配置
|
||||
type DoctorInquiryConfigService struct {
|
||||
}
|
||||
|
||||
// SystemInquiryConfigService 系统问诊配置
|
||||
type SystemInquiryConfigService struct {
|
||||
}
|
||||
|
||||
// HandleDoctorInquiryConfig 处理医生问诊配置
|
||||
func (r *DoctorInquiryConfigService) HandleDoctorInquiryConfig(doctorId int64, inquiryType, inquiryMode, isEnable, workNumDay int, inquiryPrice float64) (bool, error) {
|
||||
var err error
|
||||
|
||||
if inquiryType == 4 && inquiryMode == 1 {
|
||||
// 获取系统配置-问诊购药类型
|
||||
systemInquiryConfigDao := dao.SystemInquiryConfigDao{}
|
||||
|
||||
maps := make(map[string]interface{})
|
||||
maps["inquiry_type"] = inquiryType
|
||||
maps["inquiry_mode"] = inquiryMode
|
||||
systemInquiryConfig, _ := systemInquiryConfigDao.GetSystemInquiryConfig(maps)
|
||||
if systemInquiryConfig == nil {
|
||||
return false, errors.New("缺少系统配置")
|
||||
}
|
||||
|
||||
// 问诊人数
|
||||
workNumDay = systemInquiryConfig.MaxWorkNumDay
|
||||
|
||||
// 问诊价格
|
||||
inquiryPrice, err = strconv.ParseFloat(systemInquiryConfig.InquiryPrice, 64)
|
||||
if err != nil {
|
||||
return false, errors.New("系统价格错误")
|
||||
}
|
||||
}
|
||||
|
||||
// 开始事务
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
// 获取医生当前问诊配置
|
||||
doctorInquiryConfigDao := dao.DoctorInquiryConfigDao{}
|
||||
|
||||
maps := make(map[string]interface{})
|
||||
maps["doctor_id"] = doctorId
|
||||
maps["inquiry_type"] = inquiryType
|
||||
maps["inquiry_mode"] = inquiryMode
|
||||
d, _ := doctorInquiryConfigDao.GetDoctorInquiryConfig(maps)
|
||||
if d == nil {
|
||||
// 新增
|
||||
m := &model.DoctorInquiryConfig{
|
||||
DoctorId: doctorId,
|
||||
InquiryType: inquiryType,
|
||||
InquiryMode: inquiryMode,
|
||||
IsEnable: isEnable,
|
||||
LastEnableMethod: 2,
|
||||
WorkNumDay: workNumDay,
|
||||
InquiryPrice: inquiryPrice,
|
||||
}
|
||||
|
||||
adminUser, _ := doctorInquiryConfigDao.AddDoctorInquiryConfig(tx, m)
|
||||
if adminUser == nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("新增失败")
|
||||
}
|
||||
} else {
|
||||
// 修改
|
||||
data := make(map[string]interface{})
|
||||
|
||||
if d.IsEnable != isEnable {
|
||||
data["is_enable"] = isEnable
|
||||
}
|
||||
|
||||
if d.WorkNumDay != workNumDay {
|
||||
data["work_num_day"] = workNumDay
|
||||
}
|
||||
|
||||
if d.InquiryPrice != inquiryPrice {
|
||||
data["inquiry_price"] = inquiryPrice
|
||||
}
|
||||
|
||||
if len(data) > 0 {
|
||||
if d.LastEnableMethod != 2 {
|
||||
data["last_enable_method"] = 2
|
||||
}
|
||||
|
||||
err := doctorInquiryConfigDao.EditDoctorInquiryConfigById(tx, d.InquiryConfigId, data)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("修改失败")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
@ -1556,6 +1556,17 @@ func (r *UserDoctorService) PutMulti(doctorId int64, req requests.PutMulti) (boo
|
||||
return false, errors.New("审核失败")
|
||||
}
|
||||
|
||||
// 处理问诊配置数据
|
||||
if req.MultiPointStatus == 1 {
|
||||
// 审核通过后,创建问诊购药问诊配置
|
||||
inquiryConfigService := InquiryConfigService{}
|
||||
_, err = inquiryConfigService.HandleDoctorInquiryConfig(doctorId, 4, 1, 1, 0, 0)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("审核失败")
|
||||
}
|
||||
|
||||
}
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user