| | |
| | | "fmt" |
| | | "github.com/shopspring/decimal" |
| | | "gorm.io/gorm" |
| | | "time" |
| | | "wms/constvar" |
| | | "wms/pkg/mysqlx" |
| | | ) |
| | |
| | | OperationDate string `json:"operationDate" gorm:"type:varchar(31);comment:安排日期"` |
| | | ContacterID int `json:"contacterID" gorm:"type:int;comment:联系人ID"` |
| | | ContacterName string `json:"contacterName" gorm:"type:varchar(63);comment:联系人姓名"` |
| | | CompanyID int `json:"companyID" gorm:"type:int;comment:公司ID-客户"` |
| | | CompanyID string `json:"companyID" gorm:"type:varchar(255);comment:公司ID-客户"` |
| | | CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:公司名称-客户"` |
| | | Comment string `json:"comment" gorm:"type:text;comment:备注"` |
| | | LogisticCompanyId string `json:"logisticCompanyId" gorm:"type:varchar(191);comment:物流公司id"` |
| | |
| | | ToLocationID int `json:"toLocationId" gorm:"type:int;not null;comment:仓库位置id"` //目标位置id |
| | | ToLocation Location `json:"toLocation" gorm:"foreignKey:ToLocationID;references:Id"` //目标位置 |
| | | SalesDetailsNumber string `gorm:"type:varchar(191);comment:销售明细编码" json:"salesDetailsNumber"` |
| | | |
| | | ManagerId string `json:"managerId" gorm:"type:varchar(255);comment:主管id"` |
| | | Manager string `json:"manager" gorm:"type:varchar(255);comment:主管名称"` |
| | | AccountantId string `json:"accountantId" gorm:"type:varchar(255);comment:会计id"` |
| | | Accountant string `json:"accountant" gorm:"type:varchar(255);comment:会计名称"` |
| | | CustodianId string `json:"custodianId" gorm:"type:varchar(255);comment:保管员id"` |
| | | Custodian string `json:"custodian" gorm:"type:varchar(255);comment:保管员名称"` |
| | | CreatedBy string `json:"createBy" gorm:"type:varchar(255);comment:创建者UserId"` |
| | | CheckedBy string `json:"checkedBy" gorm:"type:varchar(255);comment:验证者UserId"` |
| | | |
| | | IsInternalOutput bool `json:"isInternalOutput"` //是否调拨产生的出库 |
| | | } |
| | | |
| | | OperationSearch struct { |
| | |
| | | Ids []int |
| | | SourceNumbers []string |
| | | SalesDetailsNumbers []string |
| | | Fields string |
| | | BeginTime time.Time |
| | | EndTime time.Time |
| | | } |
| | | ) |
| | | |
| | |
| | | |
| | | func (slf *OperationSearch) SetKeyword(keyword string) *OperationSearch { |
| | | slf.Keyword = keyword |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationSearch) SetFields(fields string) *OperationSearch { |
| | | slf.Fields = fields |
| | | return slf |
| | | } |
| | | |
| | |
| | | |
| | | func (slf *OperationSearch) SetOperationSource(operationSource constvar.OperationSource) *OperationSearch { |
| | | slf.OperationSource = operationSource |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationSearch) SetTimeBetween(beginTime, endTime time.Time) *OperationSearch { |
| | | slf.BeginTime = beginTime |
| | | slf.EndTime = endTime |
| | | return slf |
| | | } |
| | | |
| | |
| | | db = db.Where("operation_source = ?", slf.OperationSource) |
| | | } |
| | | |
| | | if slf.Fields != "" { |
| | | db = db.Select(slf.Fields) |
| | | } |
| | | |
| | | if !slf.BeginTime.IsZero() && !slf.EndTime.IsZero() { |
| | | db = db.Where("created_at between ? and ?", slf.BeginTime, slf.EndTime) |
| | | } |
| | | return db |
| | | } |
| | | |
| | |
| | | return records, nil |
| | | } |
| | | |
| | | func (slf *OperationSearch) FindIds() ([]int, error) { |
| | | var ( |
| | | records = make([]int, 0) |
| | | db = slf.build() |
| | | ) |
| | | if err := db.Find(&records).Error; err != nil { |
| | | return records, fmt.Errorf("find records err: %v", err) |
| | | } |
| | | |
| | | return records, nil |
| | | } |
| | | |
| | | // FindByQuery 指定条件查询. |
| | | func (slf *OperationSearch) FindByQuery(query string, args []interface{}) ([]*Operation, int64, error) { |
| | | var ( |