From 504f3e9bc274bcd6c7221e738802e0e5d4aef36f Mon Sep 17 00:00:00 2001 From: lishihai <dslsh@dscom> Date: 星期四, 20 六月 2024 17:07:02 +0800 Subject: [PATCH] 查询属性值和对象 通过主键ID查询 --- 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