获取药品订单列表-分页,新增了 药品数据名称
This commit is contained in:
parent
deb9a25f97
commit
f1588a096e
@ -92,6 +92,9 @@ func (r *OrderProductDao) GetOrderProductPageSearch(req requests.GetOrderProduct
|
|||||||
// 构建查询条件
|
// 构建查询条件
|
||||||
query := global.Db.Model(&model.OrderProduct{})
|
query := global.Db.Model(&model.OrderProduct{})
|
||||||
|
|
||||||
|
// 药品数据
|
||||||
|
query = query.Preload("OrderProductItem")
|
||||||
|
|
||||||
// 医生
|
// 医生
|
||||||
query = query.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
query = query.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Omit("open_id", "union_id", "wx_session_key")
|
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package dto
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"hospital-admin-api/api/model"
|
"hospital-admin-api/api/model"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// OrderProductDto 订单详情
|
// OrderProductDto 订单详情
|
||||||
@ -58,6 +59,7 @@ type OrderProductDto struct {
|
|||||||
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"` // 优惠卷
|
||||||
|
ProductName string `json:"product_name"` // 药品数据
|
||||||
}
|
}
|
||||||
|
|
||||||
// OrderProductConsigneeDto 药品订单收货人数据
|
// OrderProductConsigneeDto 药品订单收货人数据
|
||||||
@ -115,8 +117,8 @@ func GetOrderProductDto(m *model.OrderProduct) *OrderProductDto {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOrderProductConsigneeDtoDto 药品订单收货人数据
|
// GetOrderProductConsigneeDto 药品订单收货人数据
|
||||||
func GetOrderProductConsigneeDtoDto(m *model.OrderProduct) *OrderProductConsigneeDto {
|
func GetOrderProductConsigneeDto(m *model.OrderProduct) *OrderProductConsigneeDto {
|
||||||
return &OrderProductConsigneeDto{
|
return &OrderProductConsigneeDto{
|
||||||
ProvinceId: m.ProvinceId,
|
ProvinceId: m.ProvinceId,
|
||||||
Province: m.Province,
|
Province: m.Province,
|
||||||
@ -181,6 +183,11 @@ func GetOrderProductListDto(m []*model.OrderProduct) []*OrderProductDto {
|
|||||||
response = response.LoadOrderPrescriptionCode(v.OrderPrescription)
|
response = response.LoadOrderPrescriptionCode(v.OrderPrescription)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 加载药品数据
|
||||||
|
if v.OrderProductItem != nil {
|
||||||
|
response = response.LoadProductName(v.OrderProductItem)
|
||||||
|
}
|
||||||
|
|
||||||
// 将转换后的结构体添加到新切片中
|
// 将转换后的结构体添加到新切片中
|
||||||
responses[i] = response
|
responses[i] = response
|
||||||
}
|
}
|
||||||
@ -274,3 +281,21 @@ func (r *OrderProductDto) LoadOrderProductCoupon(m *model.OrderProductCoupon) *O
|
|||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadProductName 加载药品数据
|
||||||
|
func (r *OrderProductDto) LoadProductName(m []*model.OrderProductItem) *OrderProductDto {
|
||||||
|
if len(m) > 0 {
|
||||||
|
var products []string
|
||||||
|
|
||||||
|
for _, item := range m {
|
||||||
|
amount := fmt.Sprintf("%d", item.Amount)
|
||||||
|
productPrice := fmt.Sprintf("%.2f", item.ProductPrice)
|
||||||
|
|
||||||
|
product := item.ProductName + "(N:" + amount + " " + "P:" + productPrice + ")"
|
||||||
|
products = append(products, product)
|
||||||
|
|
||||||
|
r.ProductName = strings.Join(products, "; ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|||||||
@ -53,6 +53,7 @@ type OrderProduct struct {
|
|||||||
OrderInquiry *OrderInquiry `gorm:"foreignKey:OrderInquiryId;references:order_inquiry_id" json:"order_inquiry"` // 问诊
|
OrderInquiry *OrderInquiry `gorm:"foreignKey:OrderInquiryId;references:order_inquiry_id" json:"order_inquiry"` // 问诊
|
||||||
UserPatient *UserPatient `gorm:"foreignKey:PatientId;references:patient_id" json:"user_patient"` // 患者
|
UserPatient *UserPatient `gorm:"foreignKey:PatientId;references:patient_id" json:"user_patient"` // 患者
|
||||||
OrderPrescription *OrderPrescription `gorm:"foreignKey:OrderPrescriptionId;references:order_prescription_id" json:"order_prescription"` // 处方
|
OrderPrescription *OrderPrescription `gorm:"foreignKey:OrderPrescriptionId;references:order_prescription_id" json:"order_prescription"` // 处方
|
||||||
|
OrderProductItem []*OrderProductItem `gorm:"foreignKey:OrderProductId;references:order_product_id" json:"order_product_item"` // 处方
|
||||||
Model
|
Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -286,7 +286,7 @@ func (r *OrderProductService) GetOrderProductConsignee(orderProductId int64) (*d
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 处理返回值
|
// 处理返回值
|
||||||
u := dto.GetOrderProductConsigneeDtoDto(orderProduct)
|
u := dto.GetOrderProductConsigneeDto(orderProduct)
|
||||||
|
|
||||||
return u, nil
|
return u, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user