新增了立减金额
This commit is contained in:
parent
6ec1e9749f
commit
9965d8a742
@ -3,6 +3,7 @@ package dto
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"hepa-calc-api/api/model"
|
"hepa-calc-api/api/model"
|
||||||
|
"math"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SystemMemberDto 配置-会员配置
|
// SystemMemberDto 配置-会员配置
|
||||||
@ -13,6 +14,7 @@ type SystemMemberDto struct {
|
|||||||
DiscountPrice *float64 `json:"discount_price"` // 优惠价格
|
DiscountPrice *float64 `json:"discount_price"` // 优惠价格
|
||||||
DiscountEndTime *model.LocalTime `json:"discount_end_time"` // 优惠截止时间
|
DiscountEndTime *model.LocalTime `json:"discount_end_time"` // 优惠截止时间
|
||||||
FirstTimePrice *float64 `json:"first_time_price"` // 首次购买价格
|
FirstTimePrice *float64 `json:"first_time_price"` // 首次购买价格
|
||||||
|
ReductionAmount *float64 `json:"Reduction amount"` // 立减金额
|
||||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||||
}
|
}
|
||||||
@ -35,6 +37,9 @@ func GetSystemMemberListDto(m []*model.SystemMember) []*SystemMemberDto {
|
|||||||
UpdatedAt: v.UpdatedAt,
|
UpdatedAt: v.UpdatedAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 加载数据-立减金额
|
||||||
|
response = response.LoadReductionAmount(v)
|
||||||
|
|
||||||
// 将转换后的结构体添加到新切片中
|
// 将转换后的结构体添加到新切片中
|
||||||
responses[i] = response
|
responses[i] = response
|
||||||
}
|
}
|
||||||
@ -56,3 +61,15 @@ func GetSystemMemberDto(m *model.SystemMember) *SystemMemberDto {
|
|||||||
UpdatedAt: m.UpdatedAt,
|
UpdatedAt: m.UpdatedAt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadReductionAmount 加载数据-立减金额
|
||||||
|
func (r *SystemMemberDto) LoadReductionAmount(m *model.SystemMember) *SystemMemberDto {
|
||||||
|
if m.FirstTimePrice != nil {
|
||||||
|
reductionAmount := m.Price - *m.FirstTimePrice
|
||||||
|
reductionAmount = math.Round(reductionAmount*100) / 100
|
||||||
|
|
||||||
|
r.ReductionAmount = &reductionAmount
|
||||||
|
}
|
||||||
|
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user