| | |
| | | "wms/extend/util" |
| | | "wms/models" |
| | | "wms/pkg/logx" |
| | | "wms/pkg/mysqlx" |
| | | "wms/request" |
| | | ) |
| | | |
| | |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "产品信息更新失败") |
| | | 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{} |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, "请输入源单据") |
| | | return |
| | | } |
| | | if params.Number == "" { |
| | | util.ResponseFormat(c, code.RequestParamError, "请输入单号") |
| | | return |
| | | } |
| | | |
| | | var numberNum int64 |
| | | if err := mysqlx.GetDB().Model(&models.Operation{}).Where("number=?", params.Number).Count(&numberNum).Error; err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | if numberNum > 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "单号已存在") |
| | | return |
| | | } |
| | | |
| | | detail := &models.OperationDetails{ |
| | | ProductId: params.ProductId, |
| | | Amount: params.Amount, |
| | | } |
| | | operation := models.Operation{ |
| | | Number: strconv.FormatInt(time.Now().Unix(), 10), |
| | | //Number: strconv.FormatInt(time.Now().Unix(), 10), |
| | | Number: params.Number, |
| | | SourceNumber: params.SourceNumber, |
| | | OperationTypeId: 0, |
| | | Status: constvar.OperationStatus_Ready, |
| | |
| | | return |
| | | } |
| | | if err := models.WithTransaction(func(tx *gorm.DB) error { |
| | | if err := models.NewOperationSearch().SetOrm(tx).SetID(id).Update(&models.Operation{Status: constvar.OperationStatus_Finish}); err != nil { |
| | | if err := models.NewOperationSearch().SetOrm(tx).SetID(id).Update(&models.Operation{Status: constvar.OperationStatus_Finish, AuditDate: time.Now().Format("2006-01-02 15:04:05")}); err != nil { |
| | | return err |
| | | } |
| | | var listProdtId []string |
| | |
| | | return |
| | | } |
| | | operation.Status = constvar.OperationStatus_Cancel |
| | | operation.AuditDate = time.Now().Format("2006-01-02 15:04:05") |
| | | if err := models.NewOperationSearch().SetID(operation.Id).Save(operation); err != nil { |
| | | util.ResponseFormat(c, code.SaveFail, err.Error()) |
| | | return |