From 201be38fd71ee487d887e686cf07773ec750a8de Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期四, 26 十月 2023 17:56:50 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS
---
controllers/product_controller.go | 32 ++++++++++++++++++++++++--------
1 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/controllers/product_controller.go b/controllers/product_controller.go
index 9dee846..da77f6c 100644
--- a/controllers/product_controller.go
+++ b/controllers/product_controller.go
@@ -475,19 +475,35 @@
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 {
+
+ //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
+ //}
+
+ locAmount, res := models.NewLocationProductAmountSearch().
+ SetProductId(v.ID).
+ SetLocationId(operation.ToLocationID).
+ FirstRes()
+ if res.Error != nil {
return err
}
if locAmount.Amount.LessThan(value) {
- return errors.New(fmt.Sprintf("浜у搧锛�%v,搴撳瓨锛�%v,鍑哄簱锛�%v,鏁伴噺涓嶅锛屾棤娉曞畬鎴愬嚭搴撴搷浣�", v.Name, v.Amount.String(), value.String()))
+ 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 {
+ if err := models.NewLocationProductAmountSearch().SetID(locAmount.Id).Update(locAmount); err != nil {
return err
}
}
--
Gitblit v1.8.0