From 3bea96f2c557927065217c49f5f3ea50509c5924 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期六, 15 六月 2024 18:09:27 +0800 Subject: [PATCH] 库存调整列表增加多单位 --- controllers/location_product_amount.go | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/controllers/location_product_amount.go b/controllers/location_product_amount.go index ec9165c..5a62cb9 100644 --- a/controllers/location_product_amount.go +++ b/controllers/location_product_amount.go @@ -113,6 +113,32 @@ } records[k].BaseOperationType = constvar.BaseOperationTypeAdjust } + + productIds = make([]string, 0) + for _, record := range records { + productIds = append(productIds, record.ProductId) + } + + products, err := models.NewMaterialSearch().SetIDs(productIds).FindNotTotal() + if err != nil { + util.ResponseFormat(c, code.RequestError, "鏌ヨ浜у搧澶辫触") + return + } + + productMap := models.MaterialMap(products) + + for k, v := range records { + product := productMap[v.ProductId] + if product == nil { + continue + } + + moreUnit := product.MoreUnit + if moreUnit != nil && *moreUnit { + records[k].AmountMoreUnits = service.CreateMoreUnit(v.Amount, product.MoreUnitList) + } + } + util.ResponseFormatListWithPage(c, code.Success, records, int(total), params.Page, params.PageSize) } -- Gitblit v1.8.0