From 96844c22ef3fba86a55e0af1b51bc1009d6fa950 Mon Sep 17 00:00:00 2001 From: jiangshuai <291802688@qq.com> Date: 星期五, 20 十月 2023 11:57:48 +0800 Subject: [PATCH] 1.库存盘点bug修改 --- controllers/product_controller.go | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/controllers/product_controller.go b/controllers/product_controller.go index c1f0d71..b9c02b5 100644 --- a/controllers/product_controller.go +++ b/controllers/product_controller.go @@ -485,6 +485,21 @@ if err := tx.Save(listProdt[k]).Error; err != nil { return err } + var locAmount models.LocationProductAmount + if err := models.NewLocationProductAmountSearch().Orm. + Table("wms_location_product_amount"). + Joins("inner join wms_location_product on wms_location_product.id=wms_location_product_amount.location_product_id"). + Where("wms_location_product.product_id=? and wms_location_product.location_id=?", v.ID, operation.FromLocationID). + First(&locAmount).Error; err != nil { + return err + } + if locAmount.Amount.LessThan(value) { + return errors.New(fmt.Sprintf("浜у搧锛�%v,搴撳瓨锛�%v,鍑哄簱锛�%v,鏁伴噺涓嶅锛屾棤娉曞畬鎴愬嚭搴撴搷浣�", v.Name, v.Amount.String(), value.String())) + } + locAmount.Amount = locAmount.Amount.Sub(value) + if err := models.NewLocationProductAmountSearch().SetID(locAmount.Id).Update(&locAmount); err != nil { + return err + } } } return nil -- Gitblit v1.8.0