增加了药品订单详情的优惠卷数据

This commit is contained in:
2024-05-21 10:49:42 +08:00
parent 931d2def98
commit e19316cfc3
6 changed files with 191 additions and 4 deletions
+11
View File
@@ -57,6 +57,7 @@ type OrderProductDto struct {
UserDoctor *UserDoctorDto `json:"user_doctor"` // 医生数据
OrderPrescription *OrderPrescriptionDto `json:"order_prescription"` // 处方数据
OrderInquiryCase *OrderInquiryCaseDto `json:"order_inquiry_case"` // 问诊病例
OrderProductCoupon *OrderProductCouponDto `json:"order_product_coupon"` // 优惠卷
}
// OrderProductConsigneeDto 药品订单收货人数据
@@ -263,3 +264,13 @@ func (r *OrderProductDto) LoadOrderProductRefund(m *model.OrderProductRefund) *O
}
return r
}
// LoadOrderProductCoupon 加载药品订单优惠卷数据
func (r *OrderProductDto) LoadOrderProductCoupon(m *model.OrderProductCoupon) *OrderProductDto {
if m != nil {
d := GetOrderProductCouponDto(m)
r.OrderProductCoupon = d
}
return r
}
+52
View File
@@ -0,0 +1,52 @@
package dto
import (
"fmt"
"hospital-admin-api/api/model"
)
type OrderProductCouponDto struct {
OrderCouponId string `json:"order_coupon_id"` // 主键id
OrderProductId string `json:"order_product_id"` // 订单-商品id
UserCouponId string `json:"user_coupon_id"` // 用户优惠卷表id
CouponName string `json:"coupon_name"` // 优惠卷名称
CouponUsePrice float64 `json:"coupon_use_price"` // 优惠卷使用金额
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
}
func GetOrderProductCouponDto(m *model.OrderProductCoupon) *OrderProductCouponDto {
return &OrderProductCouponDto{
OrderCouponId: fmt.Sprintf("%d", m.OrderCouponId),
OrderProductId: fmt.Sprintf("%d", m.OrderProductId),
UserCouponId: fmt.Sprintf("%d", m.UserCouponId),
CouponName: m.CouponName,
CouponUsePrice: m.CouponUsePrice,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
}
}
func GetOrderProductCouponListDto(m []*model.OrderProductCoupon) []OrderProductCouponDto {
// 处理返回值
responses := make([]OrderProductCouponDto, len(m))
if len(m) > 0 {
for i, v := range m {
response := OrderProductCouponDto{
OrderCouponId: fmt.Sprintf("%d", v.OrderCouponId),
OrderProductId: fmt.Sprintf("%d", v.OrderProductId),
UserCouponId: fmt.Sprintf("%d", v.UserCouponId),
CouponName: v.CouponName,
CouponUsePrice: v.CouponUsePrice,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}
// 将转换后的结构体添加到新切片中
responses[i] = response
}
}
return responses
}