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修改 --- models/location_product_amount.go | 26 +++++++++++++++++++++++--- 1 files changed, 23 insertions(+), 3 deletions(-) diff --git a/models/location_product_amount.go b/models/location_product_amount.go index e8e0e7e..cb890e2 100644 --- a/models/location_product_amount.go +++ b/models/location_product_amount.go @@ -4,6 +4,7 @@ "fmt" "github.com/shopspring/decimal" "gorm.io/gorm" + "wms/constvar" "wms/pkg/mysqlx" ) @@ -14,6 +15,7 @@ LocationProductId int `json:"locationProductId" gorm:"type:int;not null;comment:涓婃灦瑙勫垯id"` //涓婃灦瑙勫垯id LocationProduct LocationProduct `json:"locationProduct" gorm:"foreignKey:LocationProductId;references:Id"` Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:搴撳瓨鏁伴噺"` //搴撳瓨鏁伴噺 + CreateDate string `json:"createDate" gorm:"type:varchar(63);comment:鏃ユ湡"` //鏃ユ湡 } LocationProductAmountSearch struct { @@ -27,9 +29,19 @@ } LocationProductAmountWithOperation struct { - LocationProductAmount LocationProductAmount `json:"locationProductAmount"` - AdjustAmount decimal.Decimal `json:"adjustAmount" gorm:"column:adjust_amount"` - DifferenceAmount decimal.Decimal `json:"difference_amount"` + //LocationProductAmount LocationProductAmount `json:"locationProductAmount"` + LocationProductAmountId int `json:"locationProductAmountId" gorm:"location_product_amount_id"` + LocationId int `json:"locationId" gorm:"column:location_id"` + LocationName string `json:"locationName" gorm:"column:location_name"` + ProductId string `json:"productId" gorm:"column:product_id"` + ProductName string `json:"productName" gorm:"column:product_name"` + Amount decimal.Decimal `json:"amount" gorm:"column:amount"` + Unit string `json:"unit" gorm:"column:unit"` + CreateDate string `json:"createDate" gorm:"column:create_date"` + AdjustAmount decimal.Decimal `json:"adjustAmount" gorm:"column:adjust_amount"` + DifferenceAmount decimal.Decimal `json:"differenceAmount" gorm:"-"` + OperationId int `json:"operationId" gorm:"column:operation_id"` + Status constvar.OperationStatus `json:"status" gorm:"status"` } ) @@ -71,6 +83,11 @@ return slf } +func (slf *LocationProductAmountSearch) SetLocationProductId(id int) *LocationProductAmountSearch { + slf.LocationProductId = id + return slf +} + func (slf *LocationProductAmountSearch) build() *gorm.DB { var db = slf.Orm.Model(&LocationProductAmount{}) @@ -88,6 +105,9 @@ if slf.Preload { db = db.Model(&LocationProductAmount{}).Preload("LocationProduct").Preload("LocationProduct.Location").Preload("LocationProduct.Product") } + if slf.LocationProductId != 0 { + db = db.Where("location_product_id=?", slf.LocationProductId) + } return db } -- Gitblit v1.8.0