From 76c74cf71fb82099e134cea6a34019655fed2f3f Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期二, 14 十一月 2023 14:52:37 +0800
Subject: [PATCH] 产品列表增加重订货规则统计

---
 controllers/product_controller.go |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/controllers/product_controller.go b/controllers/product_controller.go
index fa65e70..053effc 100644
--- a/controllers/product_controller.go
+++ b/controllers/product_controller.go
@@ -125,8 +125,7 @@
 		product.PredictionAmount = product.Amount.Add(reorderAmount.TotalAmount)
 
 		var statisticsList []*request.ProductStatistics
-		if err := models.NewOperationSearch().Orm.
-			Table("wms_operation").
+		if err := models.NewOperationSearch().Orm.Table("wms_operation").
 			InnerJoins("INNER JOIN wms_operation_details on wms_operation_details.operation_id=wms_operation.id").
 			Select("SUM(wms_operation_details.amount) as total_amount,wms_operation.base_operation_type").
 			Where("wms_operation_details.product_id=? and wms_operation.`status`=? and wms_operation.base_operation_type in (?)", product.ID, constvar.OperationStatus_Finish, []constvar.BaseOperationType{constvar.BaseOperationTypeIncoming, constvar.BaseOperationTypeOutgoing, constvar.BaseOperationTypeDisuse}).
@@ -146,6 +145,16 @@
 				product.OutputAmount = product.OutputAmount.Add(v.TotalAmount)
 			}
 		}
+		reorderRules, rulesTotal, err := models.NewReorderRuleSearch().SetProductId(product.ID).Find()
+		if err != nil {
+			util.ResponseFormat(c, code.RequestParamError, "閲嶈璐ц鍒欑粺璁″け璐�")
+			return
+		}
+		if rulesTotal == 1 {
+			product.MinInventoryRule = reorderRules[0].MinInventory
+			product.MaxInventoryRule = reorderRules[0].MaxInventory
+		}
+		product.ReorderRuleNum = rulesTotal
 	}
 	util.ResponseFormatList(c, code.Success, products, int(total))
 }

--
Gitblit v1.8.0