最低价格约束

This commit is contained in:
2026-04-07 13:51:19 +08:00
parent c684523cb8
commit fccb83c0e5
5 changed files with 33 additions and 3 deletions

View File

@@ -196,6 +196,14 @@ func (s *resourceService) CalcPrice(skuCode string, count int32, user *m.User, c
couponApplied = discounted.Sub(coupon.Amount)
}
// 约束到最低价格
if discounted.Cmp(sku.PriceMin) < 0 {
discounted = sku.PriceMin.Copy()
}
if couponApplied.Cmp(sku.PriceMin) < 0 {
couponApplied = sku.PriceMin.Copy()
}
return sku, discount, coupon, discounted, couponApplied, nil
}