fix
zhangqian
2023-08-29 35edc2fddbd90831ef7bf79043871c9d8d50003d
model/purchase/purchase.go
@@ -46,18 +46,19 @@
type WholeDiscountType int
const (
   WholeDiscountTypeDefault  WholeDiscountType = 0 //无折扣
   WholeDiscountTypePercent  WholeDiscountType = 1 //百分比降价
   WholeDiscountTypeDiscount WholeDiscountType = 2 //直接降价
)
func (wdt WholeDiscountType) IsValid(totalPrice, value decimal.Decimal) bool {
   if wdt != WholeDiscountTypePercent && wdt != WholeDiscountTypeDiscount {
   if wdt != WholeDiscountTypePercent && wdt != WholeDiscountTypeDiscount && wdt != WholeDiscountTypeDefault {
      return false
   }
   if wdt == WholeDiscountTypeDiscount && value.GreaterThanOrEqual(totalPrice) {
   if wdt == WholeDiscountTypeDiscount && value.GreaterThan(totalPrice) {
      return false
   }
   if wdt == WholeDiscountTypePercent && totalPrice.Mul(value).Div(decimal.NewFromInt(100)).GreaterThanOrEqual(totalPrice) {
   if wdt == WholeDiscountTypePercent && totalPrice.Mul(value).Div(decimal.NewFromInt(100)).GreaterThan(totalPrice) {
      return false
   }
   return true
@@ -74,7 +75,7 @@
   if pat != PriceAdjustmentTypeAdd && pat != PriceAdjustmentTypeSub {
      return false
   }
   if pat == PriceAdjustmentTypeSub && value.GreaterThanOrEqual(totalPrice) {
   if pat == PriceAdjustmentTypeSub && value.GreaterThan(totalPrice) {
      return false
   }
   return true