From b7ffe7edd3ace3ae7f62cadfcf7ba7ccb762364f Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 05 七月 2024 15:44:03 +0800
Subject: [PATCH] fix

---
 service/location_amount.go |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/service/location_amount.go b/service/location_amount.go
new file mode 100644
index 0000000..b6c7b69
--- /dev/null
+++ b/service/location_amount.go
@@ -0,0 +1,24 @@
+package service
+
+import (
+	"github.com/shopspring/decimal"
+	"wms/models"
+)
+
+func GetLocationAmounts(productIds []string, locationIds []int) (locationAmountMap map[string]map[int]decimal.Decimal, err error) {
+	locationAmounts, err := models.NewLocationProductAmountSearch().
+		SetProductIds(productIds).SetLocationIds(locationIds).
+		SetFields("product_id, location_id, amount").
+		Find()
+	if err != nil {
+		return nil, err
+	}
+	locationAmountMap = make(map[string]map[int]decimal.Decimal)
+	for _, locationAmount := range locationAmounts {
+		if locationAmountMap[locationAmount.ProductId] == nil {
+			locationAmountMap[locationAmount.ProductId] = make(map[int]decimal.Decimal)
+		}
+		locationAmountMap[locationAmount.ProductId][locationAmount.LocationId] = locationAmount.Amount
+	}
+	return
+}

--
Gitblit v1.8.0