From 70e86bec4055bdc2fdbff8e1aa8e8bc41c32b2f0 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期六, 21 十月 2023 17:42:42 +0800
Subject: [PATCH] 产品添加限制修改
---
models/location_product_amount.go | 53 ++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 36 insertions(+), 17 deletions(-)
diff --git a/models/location_product_amount.go b/models/location_product_amount.go
index 7ed5dea..b51e00c 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"
)
@@ -19,27 +20,29 @@
LocationProductAmountSearch struct {
LocationProductAmount
- Order string
- PageNum int
- PageSize int
- Keyword string
- Orm *gorm.DB
- Preload bool
+ Order string
+ PageNum int
+ PageSize int
+ Keyword string
+ Orm *gorm.DB
+ Preload bool
+ LocationProductIds []int
}
LocationProductAmountWithOperation struct {
//LocationProductAmount LocationProductAmount `json:"locationProductAmount"`
- LocationProductAmountId int `json:"locationProductAmount" 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"`
+ 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"`
}
)
@@ -81,6 +84,16 @@
return slf
}
+func (slf *LocationProductAmountSearch) SetLocationProductId(id int) *LocationProductAmountSearch {
+ slf.LocationProductId = id
+ return slf
+}
+
+func (slf *LocationProductAmountSearch) SetLocationProductIds(ids []int) *LocationProductAmountSearch {
+ slf.LocationProductIds = ids
+ return slf
+}
+
func (slf *LocationProductAmountSearch) build() *gorm.DB {
var db = slf.Orm.Model(&LocationProductAmount{})
@@ -98,6 +111,12 @@
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)
+ }
+ if len(slf.LocationProductIds) > 0 {
+ db = db.Where("location_product_id in (?)", slf.LocationProductIds)
+ }
return db
}
--
Gitblit v1.8.0