78 lines
2.8 KiB
Go
78 lines
2.8 KiB
Go
package dto
|
|
|
|
import (
|
|
"fmt"
|
|
"hospital-admin-api/api/model"
|
|
)
|
|
|
|
// OrderServicePackageProductDto 订单-服务包-关联商品订单表
|
|
type OrderServicePackageProductDto struct {
|
|
ServiceProductId string `json:"service_product_id"` // 主键id
|
|
OrderServiceId string `json:"order_service_id"` // 订单-服务包id
|
|
OrderProductId string `json:"order_product_id"` // 订单-商品id
|
|
OrderProductNo string `json:"order_product_no"` // 订单-商品系统编号
|
|
ProductItemId string `json:"product_item_id"` // 订单-商品明细id
|
|
ProductId string `json:"product_id"` // 商品id
|
|
UsedQuantity int `json:"used_quantity"` // 商品使用数量
|
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
|
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
|
OrderProduct *OrderProductDto `json:"order_product"` // 药品订单
|
|
}
|
|
|
|
// GetOrderServicePackageProductDto 服务包订单病例详情
|
|
func GetOrderServicePackageProductDto(m *model.OrderServicePackageProduct) *OrderServicePackageProductDto {
|
|
return &OrderServicePackageProductDto{
|
|
ServiceProductId: fmt.Sprintf("%d", m.ServiceProductId),
|
|
OrderServiceId: fmt.Sprintf("%d", m.OrderServiceId),
|
|
OrderProductId: fmt.Sprintf("%d", m.OrderProductId),
|
|
OrderProductNo: m.OrderProductNo,
|
|
ProductItemId: fmt.Sprintf("%d", m.ProductItemId),
|
|
ProductId: fmt.Sprintf("%d", m.ProductId),
|
|
UsedQuantity: m.UsedQuantity,
|
|
CreatedAt: m.CreatedAt,
|
|
UpdatedAt: m.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
// GetOrderServicePackageProductListDto 服务包订单病例列表
|
|
func GetOrderServicePackageProductListDto(m []*model.OrderServicePackageProduct) []*OrderServicePackageProductDto {
|
|
// 处理返回值
|
|
responses := make([]*OrderServicePackageProductDto, len(m))
|
|
|
|
if len(m) > 0 {
|
|
for i, v := range m {
|
|
response := &OrderServicePackageProductDto{
|
|
ServiceProductId: fmt.Sprintf("%d", v.ServiceProductId),
|
|
OrderServiceId: fmt.Sprintf("%d", v.OrderServiceId),
|
|
OrderProductId: fmt.Sprintf("%d", v.OrderProductId),
|
|
OrderProductNo: v.OrderProductNo,
|
|
ProductItemId: fmt.Sprintf("%d", v.ProductItemId),
|
|
ProductId: fmt.Sprintf("%d", v.ProductId),
|
|
UsedQuantity: v.UsedQuantity,
|
|
CreatedAt: v.CreatedAt,
|
|
UpdatedAt: v.UpdatedAt,
|
|
}
|
|
|
|
// 加载问诊订单数据
|
|
if v.OrderProduct != nil {
|
|
response = response.LoadOrderProduct(v.OrderProduct)
|
|
}
|
|
|
|
// 将转换后的结构体添加到新切片中
|
|
responses[i] = response
|
|
}
|
|
}
|
|
|
|
return responses
|
|
}
|
|
|
|
// LoadOrderProduct 加载药品订单数据
|
|
func (r *OrderServicePackageProductDto) LoadOrderProduct(m *model.OrderProduct) *OrderServicePackageProductDto {
|
|
if m != nil {
|
|
d := GetOrderProductDto(m)
|
|
|
|
r.OrderProduct = d
|
|
}
|
|
return r
|
|
}
|