From 3efb723b393ef6f516dbe1644697f0ba5536c48c Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 12 六月 2024 22:02:35 +0800 Subject: [PATCH] 月度报表统计修复 --- task/month_stats.go | 29 ++++++++++++++++------------- 1 files changed, 16 insertions(+), 13 deletions(-) diff --git a/task/month_stats.go b/task/month_stats.go index 7a507f0..6d82bb4 100644 --- a/task/month_stats.go +++ b/task/month_stats.go @@ -104,13 +104,13 @@ inputMoreValueArr := make([]models.UnitItems, 0, len(product.MoreUnitList)) outputMoreValueArr := make([]models.UnitItems, 0, len(product.MoreUnitList)) for _, unitItem := range product.MoreUnitList { - moreValueArr = append(moreValueArr, models.UnitItems{ - Amount: amount.Mul(unitItem.Amount), - Unit: unitItem.Unit, - Floating: unitItem.Floating, - }) - bys, _ := json.Marshal(moreValueArr) - moreUnits = string(bys) + if !amount.IsZero() { + moreValueArr = append(moreValueArr, models.UnitItems{ + Amount: amount.Mul(unitItem.Amount), + Unit: unitItem.Unit, + Floating: unitItem.Floating, + }) + } if !inputMap[productId].IsZero() { inputMoreValueArr = append(inputMoreValueArr, models.UnitItems{ @@ -118,9 +118,6 @@ Unit: unitItem.Unit, Floating: unitItem.Floating, }) - bys, _ = json.Marshal(inputMoreValueArr) - inputMoreUnits = string(bys) - } if !outputMap[productId].IsZero() { @@ -129,11 +126,17 @@ Unit: unitItem.Unit, Floating: unitItem.Floating, }) - bys, _ = json.Marshal(outputMoreValueArr) - outputMoreUnits = string(bys) - } } + bys, _ := json.Marshal(moreValueArr) + if len(moreValueArr) > 0 { + fmt.Println(moreValueArr) + } + moreUnits = string(bys) + bys, _ = json.Marshal(inputMoreValueArr) + inputMoreUnits = string(bys) + bys, _ = json.Marshal(outputMoreValueArr) + outputMoreUnits = string(bys) } record.BeginMoreUnits = moreUnits -- Gitblit v1.8.0