From 3bea96f2c557927065217c49f5f3ea50509c5924 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期六, 15 六月 2024 18:09:27 +0800
Subject: [PATCH] 库存调整列表增加多单位
---
models/location_product_amount.go | 1 +
controllers/location_product_amount.go | 26 ++++++++++++++++++++++++++
2 files changed, 27 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)
}
diff --git a/models/location_product_amount.go b/models/location_product_amount.go
index 62c2ac8..6490139 100644
--- a/models/location_product_amount.go
+++ b/models/location_product_amount.go
@@ -47,6 +47,7 @@
ProductId string `json:"productId" gorm:"column:product_id"`
ProductName string `json:"productName" gorm:"column:product_name"`
Amount decimal.Decimal `json:"amount" gorm:"column:amount"`
+ AmountMoreUnits []UnitItems `json:"amountMoreUnits"` //鍦ㄥ簱鏁伴噺澶氬崟浣�
Unit string `json:"unit" gorm:"column:unit"`
CreateDate string `json:"createDate" gorm:"column:create_date"`
AdjustAmount decimal.Decimal `json:"adjustAmount" gorm:"column:adjust_amount"` //宸��
--
Gitblit v1.8.0