| | |
| | | return |
| | | } |
| | | |
| | | var productIds []string |
| | | for _, v := range params.Details { |
| | | productIds = append(productIds, v.ProductId) |
| | | } |
| | | products, err := models.NewMaterialSearch().SetIDs(productIds).FindNotTotal() |
| | | if err != nil { |
| | | logx.Errorf("MonthStats get products err:%v", err) |
| | | return |
| | | } |
| | | productMap := models.MaterialMap(products) |
| | | for i, v := range params.Details { |
| | | material := productMap[v.ProductId] |
| | | if material != nil { |
| | | params.Details[i].Note = material.Note |
| | | } |
| | | } |
| | | |
| | | if err := models.NewOperationSearch().Create(¶ms); err != nil { |
| | | logx.Errorf("Operation create err: %v", err) |
| | | util.ResponseFormat(c, code.SaveFail, "添加失败:"+err.Error()) |
| | |
| | | return errors.New("请选择源位置") |
| | | } |
| | | } |
| | | |
| | | } |
| | | return nil |
| | | } |
| | |
| | | } |
| | | operation, err := models.NewOperationSearch().SetID(id).First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "未找到相关出入库信息:"+err.Error()) |
| | | util.ResponseFormat(c, code.RequestParamError, "未找到相关出入库单据:"+err.Error()) |
| | | return |
| | | } |
| | | userInfo := middleware.GetUserInfo(c) |
| | | if operation.CreatedBy != userInfo.Username { |
| | | util.ResponseFormat(c, code.RequestError, "别人的出入库单据无法进行删除") |
| | | return |
| | | } |
| | | if operation.Status != constvar.OperationStatus_Ready { |
| | | util.ResponseFormat(c, code.RequestError, "该入库信息无法进行删除") |
| | | util.ResponseFormat(c, code.RequestError, "该出入库单据无法进行删除") |
| | | return |
| | | } |
| | | if err := models.WithTransaction(func(tx *gorm.DB) error { |