新增了:发放系统优惠卷

This commit is contained in:
2024-05-31 17:21:26 +08:00
parent d207720a4c
commit 7b021906a2
14 changed files with 767 additions and 24 deletions
+17 -3
View File
@@ -18,6 +18,7 @@ type UserCouponDto struct {
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
Coupon *CouponDto `json:"coupon"` // 优惠卷
UserName string `json:"user_name"` // 用户名称
}
// GetUserCouponDto 用户优惠卷详情
@@ -28,7 +29,7 @@ func GetUserCouponDto(m *model.UserCoupon) *UserCouponDto {
PatientId: fmt.Sprintf("%d", m.PatientId),
CouponId: fmt.Sprintf("%d", m.CouponId),
UserCouponStatus: m.UserCouponStatus,
CouponUseDate: model.LocalTime(m.CouponUseDate),
CouponUseDate: model.LocalTime(*m.CouponUseDate),
ValidStartTime: model.LocalTime(m.ValidStartTime),
ValidEndTime: model.LocalTime(m.ValidEndTime),
CreatedAt: m.CreatedAt,
@@ -49,18 +50,23 @@ func GetUserCouponListDto(m []*model.UserCoupon) []*UserCouponDto {
PatientId: fmt.Sprintf("%d", v.PatientId),
CouponId: fmt.Sprintf("%d", v.CouponId),
UserCouponStatus: v.UserCouponStatus,
CouponUseDate: model.LocalTime(v.CouponUseDate),
CouponUseDate: model.LocalTime(*v.CouponUseDate),
ValidStartTime: model.LocalTime(v.ValidStartTime),
ValidEndTime: model.LocalTime(v.ValidEndTime),
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}
// 加载问诊订单数据
// 加载优惠卷数据
if v.Coupon != nil {
response = response.LoadCoupon(v.Coupon)
}
// 加载用户属性
if v.User != nil {
response = response.LoadUserAttr(v.User)
}
// 将转换后的结构体添加到新切片中
responses[i] = response
}
@@ -78,3 +84,11 @@ func (r *UserCouponDto) LoadCoupon(m *model.Coupon) *UserCouponDto {
}
return r
}
// LoadUserAttr 加载用户属性
func (r *UserCouponDto) LoadUserAttr(m *model.User) *UserCouponDto {
if m != nil {
r.UserName = m.UserName
}
return r
}