新增了立减金额2
This commit is contained in:
parent
83c0362ff7
commit
f5ccb4de2f
@ -6,6 +6,7 @@ import (
|
|||||||
"hepa-calc-api/api/dto"
|
"hepa-calc-api/api/dto"
|
||||||
"hepa-calc-api/api/responses"
|
"hepa-calc-api/api/responses"
|
||||||
"hepa-calc-api/api/service"
|
"hepa-calc-api/api/service"
|
||||||
|
"math"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SystemMember struct{}
|
type SystemMember struct{}
|
||||||
@ -40,7 +41,7 @@ func (b *SystemMember) GetSystemMember(c *gin.Context) {
|
|||||||
|
|
||||||
// GetSystemMemberLeast 获取会员配置数据-最少立减金额
|
// GetSystemMemberLeast 获取会员配置数据-最少立减金额
|
||||||
func (b *SystemMember) GetSystemMemberLeast(c *gin.Context) {
|
func (b *SystemMember) GetSystemMemberLeast(c *gin.Context) {
|
||||||
var firstTimePrice *float64
|
var reductionAmount *float64
|
||||||
|
|
||||||
// 检测用户是否购买过会员
|
// 检测用户是否购买过会员
|
||||||
userId := c.GetInt64("UserId")
|
userId := c.GetInt64("UserId")
|
||||||
@ -48,7 +49,7 @@ func (b *SystemMember) GetSystemMemberLeast(c *gin.Context) {
|
|||||||
userService := service.UserService{}
|
userService := service.UserService{}
|
||||||
isBuy := userService.CheckUserBuyMember(userId)
|
isBuy := userService.CheckUserBuyMember(userId)
|
||||||
if isBuy == true {
|
if isBuy == true {
|
||||||
responses.OkWithData(firstTimePrice, c)
|
responses.OkWithData(reductionAmount, c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,15 +68,18 @@ func (b *SystemMember) GetSystemMemberLeast(c *gin.Context) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if firstTimePrice == nil {
|
amount := member.Price - *member.FirstTimePrice
|
||||||
firstTimePrice = member.FirstTimePrice
|
amount = math.Round(amount*100) / 100
|
||||||
|
|
||||||
|
if reductionAmount == nil {
|
||||||
|
reductionAmount = &amount
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if *firstTimePrice > *member.FirstTimePrice {
|
if amount < *reductionAmount {
|
||||||
firstTimePrice = member.FirstTimePrice
|
reductionAmount = &amount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
responses.OkWithData(firstTimePrice, c)
|
responses.OkWithData(reductionAmount, c)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user