修改了立减金额

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
+5 -9
View File
@@ -6,7 +6,6 @@ import (
"hepa-calc-api/api/dto"
"hepa-calc-api/api/responses"
"hepa-calc-api/api/service"
"math"
)
type SystemMember struct{}
@@ -29,7 +28,7 @@ func (b *SystemMember) GetSystemMember(c *gin.Context) {
isBuy := userService.CheckUserBuyMember(userId)
if isBuy == true {
for _, member := range systemMembers {
member.FirstTimePrice = nil
member.ReductionAmount = nil
}
}
@@ -64,20 +63,17 @@ func (b *SystemMember) GetSystemMemberLeast(c *gin.Context) {
}
for _, member := range systemMembers {
if member.FirstTimePrice == nil {
if member.ReductionAmount == nil {
continue
}
amount := member.Price - *member.FirstTimePrice
amount = math.Round(amount*100) / 100
if reductionAmount == nil {
reductionAmount = &amount
reductionAmount = member.ReductionAmount
continue
}
if amount < *reductionAmount {
reductionAmount = &amount
if *member.ReductionAmount < *reductionAmount {
reductionAmount = member.ReductionAmount
}
}