| | |
| | | CheckedBy string `json:"checkedBy" gorm:"type:varchar(255);comment:验证者UserId"` |
| | | Remark string `json:"remark"` |
| | | |
| | | WarehouseId int `json:"warehouseId" gorm:"type:int;not null;comment:仓库id"` |
| | | IsInternalOutput bool `json:"isInternalOutput"` //是否调拨产生的出库 |
| | | WarehouseId int `json:"warehouseId" gorm:"type:int;not null;comment:仓库id"` |
| | | Warehouse Warehouse `json:"warehouse" gorm:"foreignKey:WarehouseId"` |
| | | IsInternalOutput bool `json:"isInternalOutput"` //是否调拨产生的出库 |
| | | InventoryDealerType int `json:"inventoryDealerType" gorm:"type:varchar(255);comment:调拨出入库分类(对应dict字典表的ID)"` |
| | | InventoryDealer MiniDict `json:"inventoryDealer" gorm:"foreignKey:InventoryDealerType;"` |
| | | } |
| | | |
| | | OperationSearch struct { |
| | | Operation |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | | Keyword string |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | Disuse bool |
| | | Ids []int |
| | | SourceNumbers []string |
| | | SalesDetailsNumbers []string |
| | | Fields string |
| | | BeginTime time.Time |
| | | EndTime time.Time |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | | Keyword string |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | Disuse bool |
| | | Ids []int |
| | | SourceNumbers []string |
| | | SalesDetailsNumbers []string |
| | | Fields string |
| | | BeginTime time.Time |
| | | EndTime time.Time |
| | | InventoryDealerTypeIds []int // |
| | | } |
| | | ) |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationSearch) SetInventoryDealerTypeIds(inventoryDealerTypeArr []int) *OperationSearch { |
| | | slf.InventoryDealerTypeIds = inventoryDealerTypeArr |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationSearch) SetWarehouseId(warehouseId int) *OperationSearch { |
| | | slf.WarehouseId = warehouseId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&Operation{}) |
| | | |
| | |
| | | } |
| | | |
| | | if slf.Preload { |
| | | db = db.Model(&Operation{}).Preload("Details").Preload("Details.Product").Preload("LogisticCompany").Preload("Location").Preload("ToLocation").Preload("Details.FromLocation").Preload("Details.ToLocation") |
| | | db = db.Model(&Operation{}).Preload("Details"). |
| | | Preload("Details.Product"). |
| | | Preload("LogisticCompany"). |
| | | Preload("Location"). |
| | | Preload("ToLocation"). |
| | | Preload("Details.FromLocation"). |
| | | Preload("Details.ToLocation"). |
| | | Preload("InventoryDealer").Preload("Warehouse") |
| | | } |
| | | |
| | | if slf.Disuse { |
| | |
| | | if !slf.BeginTime.IsZero() && !slf.EndTime.IsZero() { |
| | | db = db.Where("created_at between ? and ?", slf.BeginTime, slf.EndTime) |
| | | } |
| | | |
| | | if len(slf.InventoryDealerTypeIds) > 0 { |
| | | db = db.Where("inventory_dealer_type in (?)", slf.InventoryDealerTypeIds) |
| | | } |
| | | |
| | | if slf.WarehouseId != 0 { |
| | | db = db.Where("warehouse_id = ?", slf.WarehouseId) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |