| | |
| | | CategoryId int `gorm:"type:int(11);comment:产品类别id" json:"categoryId"` //产品类别id |
| | | CategoryName string `gorm:"type:varchar(255);comment:产品类别名称" json:"categoryName"` //产品类别名称 |
| | | InternalReference string `gorm:"type:varchar(255);comment:内部参考" json:"internalReference"` //内部参考 |
| | | Barcode string `gorm:"type:varchar(255);comment:条码" json:"barcode"` //条码 |
| | | ProductTagId int `gorm:"type:int(11);comment:产品标签id" json:"productTagId"` //产品标签id |
| | | ProductTagName string `gorm:"type:varchar(255);comment:产品标签名称" json:"productTagName"` //产品标签名称 |
| | | CompanyId int `gorm:"type:int(11);comment:公司id" json:"companyId"` //公司id |
| | |
| | | ReorderRuleNum int64 `json:"reorderRuleNum"` |
| | | MoreUnit *bool `json:"moreUnit" gorm:"type:tinyint(1);default:false;comment:启动多单位"` |
| | | MoreUnitList []UnitItems `json:"moreUnitList" gorm:"-"` |
| | | MoreUnitValue string `json:"-" gorm:"type:varchar(255);comment:多单位值"` |
| | | MoreUnitValue string `json:"-" gorm:"type:varchar(255);comment:多单位值"` //多单位换算比例 |
| | | StockMoreUnitList []UnitItems `json:"-" gorm:"-"` //多单位存储的值 |
| | | StockMoreUnitValue string `json:"-" gorm:"type:varchar(512);comment:多单位值"` //多单位存储的值 |
| | | GrossWeight decimal.Decimal `json:"grossWeight" gorm:"type:decimal(20,3);comment:毛重"` |
| | | NetWeight decimal.Decimal `json:"netWeight" gorm:"type:decimal(20,3);comment:净重"` |
| | | GrossUnit string `json:"grossUnit" gorm:"type:varchar(255);comment:毛重单位"` |
| | |
| | | MinInventoryRule decimal.Decimal `json:"minInventoryRule" gorm:"-"` //最小库存 |
| | | MaxInventoryRule decimal.Decimal `json:"maxInventoryRule" gorm:"-"` //最大库存 |
| | | |
| | | CreateBy string `gorm:"type:varchar(255);comment:导入人、创建人" json:"createBy"` //创建人 |
| | | BarCode string `gorm:"type:varchar(255);comment:(商品/产品/物料的)条形码" json:"barCode"` //条码 |
| | | } |
| | | |
| | | MaterialSearch struct { |
| | |
| | | } |
| | | |
| | | UnitItems struct { |
| | | Amount decimal.Decimal `json:"amount"` |
| | | Amount decimal.Decimal `json:"amount"` //在物料中为换算率(1辅单位=换算率*主单位),在明细或库存中为具体值 |
| | | Unit string `json:"unit"` |
| | | Floating bool `json:"floating"` //是否浮动利率 |
| | | } |
| | |
| | | } |
| | | } |
| | | if len(slf.MoreUnitList) != 0 { |
| | | str, err := json.Marshal(slf.MoreUnitList) |
| | | items := make([]UnitItems, 0) |
| | | for k, item := range slf.MoreUnitList { |
| | | if item.Unit != "" && !item.Amount.IsZero() { |
| | | items = append(items, slf.MoreUnitList[k]) |
| | | } |
| | | } |
| | | |
| | | str, err := json.Marshal(items) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | slf.MoreUnitValue = string(str) |
| | | } |
| | | if len(slf.StockMoreUnitList) != 0 { |
| | | items := make([]UnitItems, 0) |
| | | for k, item := range slf.StockMoreUnitList { |
| | | if item.Unit != "" && !item.Amount.IsZero() { |
| | | items = append(items, slf.StockMoreUnitList[k]) |
| | | } |
| | | } |
| | | |
| | | str, err := json.Marshal(items) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | slf.StockMoreUnitValue = string(str) |
| | | } |
| | | return |
| | | } |
| | |
| | | |
| | | func (slf *MaterialSearch) SetID(id string) *MaterialSearch { |
| | | slf.ID = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *MaterialSearch) SetBarCode(barCode string) *MaterialSearch { |
| | | slf.BarCode = barCode |
| | | return slf |
| | | } |
| | | |
| | |
| | | if slf.ID != "" { |
| | | db = db.Where("id = ?", slf.ID) |
| | | } |
| | | if slf.BarCode != "" { |
| | | db = db.Where("bar_code = ?", slf.BarCode) |
| | | } |
| | | |
| | | if slf.Name != "" { |
| | | db = db.Where("name = ?", slf.Name) |