From 7d4ad4c22a254fcc3a99c543533f0dddbadaeb7e Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 26 六月 2024 19:47:59 +0800 Subject: [PATCH] 多单位保存时,不保存值或单位为0的 --- service/more_units.go | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/service/more_units.go b/service/more_units.go index 729ce4a..5abdb09 100644 --- a/service/more_units.go +++ b/service/more_units.go @@ -11,6 +11,9 @@ func CreateMoreUnit(amount decimal.Decimal, units []models.UnitItems) []models.UnitItems { moreValueArr := make([]models.UnitItems, 0, len(units)) for _, unitItem := range units { + if unitItem.Amount.IsZero() { + continue + } moreValueArr = append(moreValueArr, models.UnitItems{ Amount: amount.Div(unitItem.Amount), Unit: unitItem.Unit, -- Gitblit v1.8.0