From ed81fc8d860adb66676d4990e4ce0ff56cff79a6 Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期三, 22 十一月 2023 19:48:16 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS

---
 controllers/product_controller.go |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/controllers/product_controller.go b/controllers/product_controller.go
index a7e5abd..3a40e59 100644
--- a/controllers/product_controller.go
+++ b/controllers/product_controller.go
@@ -214,6 +214,22 @@
 		return
 	}
 
+	//鏇存柊鍦ㄥ簱鐨勪骇鍝佺被鍨�
+	if params.CategoryId > 0 {
+		find, _ := models.NewLocationProductAmountSearch().SetProductId(params.ID).Find()
+		if len(find) > 0 {
+			var ids []int
+			for _, f := range find {
+				if f.ProductCategoryID != params.CategoryId {
+					ids = append(ids, f.Id)
+				}
+			}
+			m := make(map[string]interface{})
+			m["productCategoryId"] = params.CategoryId
+			_ = models.NewLocationProductAmountSearch().SetIds(ids).UpdateByMap(m)
+		}
+	}
+
 	materialAttachmentList := []*models.MaterialAttachment{}
 	for _, v := range params.AttachmentIDs {
 		ma := &models.MaterialAttachment{MaterialID: params.ID, AttachmentID: v}
@@ -318,7 +334,7 @@
 		return
 	}
 
-	first, err := models.NewProductCategorySearch().SetID(cast.ToUint(id)).First()
+	first, err := models.NewProductCategorySearch().SetID(cast.ToInt(id)).First()
 	if err != nil {
 		util.ResponseFormat(c, code.RequestParamError, "鏌ユ壘澶辫触")
 		return
@@ -343,7 +359,7 @@
 		util.ResponseFormat(c, code.RequestParamError, "浜у搧绫诲瀷鍚嶇О涓嶈兘涓虹┖")
 		return
 	}
-	err := models.NewProductCategorySearch().SetID(params.ID).Save(&params)
+	err := models.NewProductCategorySearch().SetID(params.Id).Save(&params)
 	if err != nil {
 		util.ResponseFormat(c, code.RequestParamError, "浜у搧绫诲瀷淇℃伅鏇存柊澶辫触")
 		return
@@ -364,7 +380,7 @@
 		util.ResponseFormat(c, code.RequestParamError, "鏃犳晥id")
 		return
 	}
-	err := models.NewProductCategorySearch().SetID(cast.ToUint(id)).Delete()
+	err := models.NewProductCategorySearch().SetID(cast.ToInt(id)).Delete()
 	if err != nil {
 		util.ResponseFormat(c, code.RequestParamError, "鍒犻櫎澶辫触")
 		return
@@ -575,7 +591,7 @@
 
 				locAmount, res := models.NewLocationProductAmountSearch().
 					SetProductId(v.ID).
-					SetLocationId(operation.ToLocationID).
+					SetLocationId(operation.FromLocationID).
 					FirstRes()
 				if res.Error != nil {
 					return err
@@ -692,7 +708,7 @@
 	search := models.NewOperationSearch().SetPage(params.Page, params.PageSize).SetPreload(true).SetOrder("created_at desc")
 	search.SetOrm(search.Orm.InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").Where("wms_operation_details.product_id=? and (wms_operation.from_location_id=? or wms_operation.to_location_id=?)", params.ProductId, params.LocationId, params.LocationId))
 
-	list, total, err := search.Find()
+	list, total, err := search.SetBaseOperationType(constvar.BaseOperationTypeAdjust).Find()
 	if err != nil {
 		util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触:"+err.Error())
 		return

--
Gitblit v1.8.0