From 79aef24a785581d95343ccd99e9cb362b2bc9c97 Mon Sep 17 00:00:00 2001
From: yinbentan <yinbentan@live.com>
Date: 星期六, 06 七月 2024 21:31:59 +0800
Subject: [PATCH] 调整库存商品位置错误

---
 models/operation_details.go |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/models/operation_details.go b/models/operation_details.go
index 8269f76..f51f399 100644
--- a/models/operation_details.go
+++ b/models/operation_details.go
@@ -4,6 +4,7 @@
 	"fmt"
 	"github.com/shopspring/decimal"
 	"gorm.io/gorm"
+	"wms/constvar"
 	"wms/pkg/mysqlx"
 )
 
@@ -11,11 +12,13 @@
 	// OperationDetails 鎿嶄綔鏄庣粏琛�
 	OperationDetails struct {
 		WmsModel
-		Id          int    `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
-		OperationID int    `json:"operationId" gorm:"index;type:int;not null;comment:鎿嶄綔璁板綍id"` //鎿嶄綔id
-		ProductId   string `json:"productId" gorm:"type:varchar(191);not null;comment:浜у搧id"`  //浜у搧id
+		Id                int                        `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+		OperationID       int                        `json:"operationId" gorm:"index;type:int;not null;comment:鎿嶄綔璁板綍id"`     //鎿嶄綔id
+		BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:鍩虹浣滀笟绫诲瀷"` //鍩虹浣滀笟绫诲瀷
+		ProductId         string                     `json:"productId" gorm:"type:varchar(191);not null;comment:浜у搧id"`      //浜у搧id
 		//ProductName string          `json:"productName" gorm:"type:varchar(255);not null;comment:浜у搧鍚嶇О"` //浜у搧鍚嶇О
-		Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:鏁伴噺"` //鏁伴噺
+		Amount      decimal.Decimal `json:"amount" gorm:"type:decimal(30,10);not null;comment:鏁伴噺"` //鏁伴噺
+		StockAmount decimal.Decimal `json:"stockAmount" gorm:"type:decimal(30,10);"`               //搴撳瓨鏁伴噺锛岀洏鐐规椂鐢�
 		//Unit        string          `json:"unit" gorm:"type:varchar(31);comment:鍗曚綅"`                    //鍗曚綅
 		Product Material `json:"product" gorm:"foreignKey:ProductId;references:ID"`
 
@@ -106,6 +109,11 @@
 	return slf
 }
 
+func (slf *OperationDetailsSearch) SetBaseOperationType(baseOperationType constvar.BaseOperationType) *OperationDetailsSearch {
+	slf.BaseOperationType = baseOperationType
+	return slf
+}
+
 func (slf *OperationDetailsSearch) build() *gorm.DB {
 	var db = slf.Orm.Model(&OperationDetails{})
 
@@ -139,6 +147,10 @@
 		db = db.Select(slf.Fields)
 	}
 
+	if slf.BaseOperationType != 0 {
+		db = db.Where("base_operation_type = ?", slf.BaseOperationType)
+	}
+
 	return db
 }
 

--
Gitblit v1.8.0