| | |
| | | return |
| | | } |
| | | |
| | | //更新在库的产品类型 |
| | | if params.CategoryId > 0 { |
| | | find, _ := models.NewLocationProductAmountSearch().SetProductId(params.ID).Find() |
| | | if len(find) > 0 { |
| | | var ids []int |
| | | for _, f := range find { |
| | | if f.ProductCategoryID != params.CategoryId { |
| | | ids = append(ids, f.Id) |
| | | } |
| | | } |
| | | m := make(map[string]interface{}) |
| | | m["productCategoryId"] = params.CategoryId |
| | | _ = models.NewLocationProductAmountSearch().SetIds(ids).UpdateByMap(m) |
| | | } |
| | | } |
| | | |
| | | materialAttachmentList := []*models.MaterialAttachment{} |
| | | for _, v := range params.AttachmentIDs { |
| | | ma := &models.MaterialAttachment{MaterialID: params.ID, AttachmentID: v} |
| | |
| | | //LocationProductIds []int |
| | | LocationIds []int |
| | | ProductIds []string |
| | | Ids []int |
| | | } |
| | | |
| | | LocationProductAmountWithOperation struct { |
| | |
| | | |
| | | func (slf *LocationProductAmountSearch) SetID(id int) *LocationProductAmountSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductAmountSearch) SetIds(ids []int) *LocationProductAmountSearch { |
| | | slf.Ids = ids |
| | | return slf |
| | | } |
| | | |
| | |
| | | |
| | | if slf.ProductId != "" { |
| | | db = db.Where("product_id=?", slf.ProductId) |
| | | } |
| | | |
| | | if len(slf.Ids) > 0 { |
| | | db = db.Where("id in (?)", slf.Ids) |
| | | } |
| | | |
| | | return db |
| | |
| | | |
| | | return record, db.First(&record) |
| | | } |
| | | |
| | | func (slf *LocationProductAmountSearch) Count() (int64, error) { |
| | | var ( |
| | | total int64 |
| | | db = slf.build() |
| | | ) |
| | | err := db.Count(&total).Error |
| | | return total, err |
| | | } |
| | | |
| | | func (slf *LocationProductAmountSearch) UpdateByMap(upMap map[string]interface{}) error { |
| | | var ( |
| | | db = slf.build() |
| | | ) |
| | | |
| | | if err := db.Updates(upMap).Error; err != nil { |
| | | return fmt.Errorf("update by map err: %v, upMap: %+v", err, upMap) |
| | | } |
| | | |
| | | return nil |
| | | } |