wer
This commit is contained in:
parent
0f8693f1c8
commit
c1cb96c01e
@ -25,7 +25,21 @@ func (r *OrderProductDao) GetOrderProductById(orderProductId int64) (m *model.Or
|
|||||||
|
|
||||||
// GetOrderProductPreloadById 获取药品订单数据-加载全部关联-药品订单id
|
// GetOrderProductPreloadById 获取药品订单数据-加载全部关联-药品订单id
|
||||||
func (r *OrderProductDao) GetOrderProductPreloadById(orderProductId int64) (m *model.OrderProduct, err error) {
|
func (r *OrderProductDao) GetOrderProductPreloadById(orderProductId int64) (m *model.OrderProduct, err error) {
|
||||||
err = global.Db.Preload(clause.Associations).First(&m, orderProductId).Error
|
query := global.Db.Model(&model.OrderProduct{})
|
||||||
|
|
||||||
|
// 预加载所有关联
|
||||||
|
query = query.Preload(clause.Associations)
|
||||||
|
|
||||||
|
// 处方关联问诊表(抄方用)
|
||||||
|
query = query.Preload("OrderInquiry", func(db *gorm.DB) *gorm.DB {
|
||||||
|
return db.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||||
|
return db.Select("user_id", "user_name", "doctor_id")
|
||||||
|
}).Preload("TransferUserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||||
|
return db.Select("user_id", "user_name", "doctor_id")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
err = query.First(&m, orderProductId).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -132,7 +146,12 @@ func (r *OrderProductDao) GetOrderProductPageSearch(req requests.GetOrderProduct
|
|||||||
|
|
||||||
// 问诊订单
|
// 问诊订单
|
||||||
query = query.Preload("OrderInquiry", func(db *gorm.DB) *gorm.DB {
|
query = query.Preload("OrderInquiry", func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Select("order_inquiry_id", "patient_name_mask", "patient_sex", "patient_age")
|
return db.Select("order_inquiry_id", "patient_name_mask", "patient_sex", "patient_age").
|
||||||
|
Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||||
|
return db.Select("user_id", "user_name", "doctor_id")
|
||||||
|
}).Preload("TransferUserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||||
|
return db.Select("user_id", "user_name", "doctor_id")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// 患者名称
|
// 患者名称
|
||||||
|
|||||||
@ -55,7 +55,8 @@ type OrderProductDto struct {
|
|||||||
OrderProductRefund *OrderProductRefundDto `json:"order_product_refund"` // 退款数据
|
OrderProductRefund *OrderProductRefundDto `json:"order_product_refund"` // 退款数据
|
||||||
OrderProductItem []*OrderProductItemDto `json:"order_product_item"` // 商品数据
|
OrderProductItem []*OrderProductItemDto `json:"order_product_item"` // 商品数据
|
||||||
OrderProductLogistics *OrderProductLogisticsDto `json:"order_product_logistics"` // 物流数据
|
OrderProductLogistics *OrderProductLogisticsDto `json:"order_product_logistics"` // 物流数据
|
||||||
UserDoctor *UserDoctorDto `json:"user_doctor"` // 医生数据
|
UserDoctor *UserDoctorDto `json:"user_doctor"` // 原始医生
|
||||||
|
TransferUserDoctor *UserDoctorDto `json:"transfer_user_doctor"` // 接受抄方的医生
|
||||||
OrderPrescription *OrderPrescriptionDto `json:"order_prescription"` // 处方数据
|
OrderPrescription *OrderPrescriptionDto `json:"order_prescription"` // 处方数据
|
||||||
OrderInquiryCase *OrderInquiryCaseDto `json:"order_inquiry_case"` // 问诊病例
|
OrderInquiryCase *OrderInquiryCaseDto `json:"order_inquiry_case"` // 问诊病例
|
||||||
OrderProductCoupon *OrderProductCouponDto `json:"order_product_coupon"` // 优惠卷
|
OrderProductCoupon *OrderProductCouponDto `json:"order_product_coupon"` // 优惠卷
|
||||||
@ -179,6 +180,16 @@ func GetOrderProductListDto(m []*model.OrderProduct) []*OrderProductDto {
|
|||||||
response = response.LoadOrderInquiryAttr(v.OrderInquiry)
|
response = response.LoadOrderInquiryAttr(v.OrderInquiry)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 加载原始医生信息
|
||||||
|
if v.OrderInquiry != nil && v.OrderInquiry.UserDoctor != nil {
|
||||||
|
response = response.LoadUserDoctor(v.OrderInquiry.UserDoctor)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载接受抄方的医生信息
|
||||||
|
if v.OrderInquiry != nil && v.OrderInquiry.TransferUserDoctor != nil {
|
||||||
|
response = response.LoadTransferUserDoctor(v.OrderInquiry.TransferUserDoctor)
|
||||||
|
}
|
||||||
|
|
||||||
// 加载处方编号
|
// 加载处方编号
|
||||||
if v.OrderPrescription != nil {
|
if v.OrderPrescription != nil {
|
||||||
response = response.LoadOrderPrescriptionCode(v.OrderPrescription)
|
response = response.LoadOrderPrescriptionCode(v.OrderPrescription)
|
||||||
@ -205,6 +216,22 @@ func (r *OrderProductDto) LoadDoctorName(m *model.UserDoctor) *OrderProductDto {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadUserDoctor 加载原始医生信息
|
||||||
|
func (r *OrderProductDto) LoadUserDoctor(m *model.UserDoctor) *OrderProductDto {
|
||||||
|
if m != nil {
|
||||||
|
r.UserDoctor = GetUserDoctorDto(m)
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadTransferUserDoctor 加载接受抄方的医生信息
|
||||||
|
func (r *OrderProductDto) LoadTransferUserDoctor(m *model.UserDoctor) *OrderProductDto {
|
||||||
|
if m != nil {
|
||||||
|
r.TransferUserDoctor = GetUserDoctorDto(m)
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
// LoadOrderInquiryAttr 加载问诊属性
|
// LoadOrderInquiryAttr 加载问诊属性
|
||||||
func (r *OrderProductDto) LoadOrderInquiryAttr(m *model.OrderInquiry) *OrderProductDto {
|
func (r *OrderProductDto) LoadOrderInquiryAttr(m *model.OrderInquiry) *OrderProductDto {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
|
|||||||
@ -68,6 +68,16 @@ func (r *OrderProductService) GetOrderProduct(orderProductId int64) (g *dto.Orde
|
|||||||
// 加载医生数据
|
// 加载医生数据
|
||||||
g.UserDoctor = userDoctor
|
g.UserDoctor = userDoctor
|
||||||
|
|
||||||
|
// 加载原始医生信息
|
||||||
|
if orderProduct.OrderInquiry != nil && orderProduct.OrderInquiry.UserDoctor != nil {
|
||||||
|
g.LoadUserDoctor(orderProduct.OrderInquiry.UserDoctor)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载接受抄方的医生信息
|
||||||
|
if orderProduct.OrderInquiry != nil && orderProduct.OrderInquiry.TransferUserDoctor != nil {
|
||||||
|
g.LoadTransferUserDoctor(orderProduct.OrderInquiry.TransferUserDoctor)
|
||||||
|
}
|
||||||
|
|
||||||
// 加载问诊病例
|
// 加载问诊病例
|
||||||
g.LoadOrderInquiryCase(orderInquiryCase)
|
g.LoadOrderInquiryCase(orderInquiryCase)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user