修改了立减金额

This commit is contained in:
2024-09-09 11:08:44 +08:00
parent f5ccb4de2f
commit a0b6ffce91
5 changed files with 24 additions and 43 deletions
+1 -10
View File
@@ -3,7 +3,6 @@ package dto
import (
"fmt"
"hepa-calc-api/api/model"
"math"
)
// SystemMemberDto 配置-会员配置
@@ -13,7 +12,6 @@ type SystemMemberDto struct {
Price float64 `json:"price"` // 价格(原价)
DiscountPrice *float64 `json:"discount_price"` // 优惠价格
DiscountEndTime *model.LocalTime `json:"discount_end_time"` // 优惠截止时间
FirstTimePrice *float64 `json:"first_time_price"` // 首次购买价格
ReductionAmount *float64 `json:"reduction_amount"` // 立减金额
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
@@ -32,7 +30,6 @@ func GetSystemMemberListDto(m []*model.SystemMember) []*SystemMemberDto {
Price: v.Price,
DiscountPrice: v.DiscountPrice,
DiscountEndTime: v.DiscountEndTime,
FirstTimePrice: v.FirstTimePrice,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}
@@ -56,7 +53,6 @@ func GetSystemMemberDto(m *model.SystemMember) *SystemMemberDto {
Price: m.Price,
DiscountPrice: m.DiscountPrice,
DiscountEndTime: m.DiscountEndTime,
FirstTimePrice: m.FirstTimePrice,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
}
@@ -64,12 +60,7 @@ func GetSystemMemberDto(m *model.SystemMember) *SystemMemberDto {
// 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
}
r.ReductionAmount = m.ReductionAmount
return r
}