| | |
| | | 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 key, value := range productMap { |
| | | for i := 0; i < len(params.Details); i++ { |
| | | if key == params.Details[i].ProductId { |
| | | params.Details[i].Note = value.Note |
| | | break |
| | | } |
| | | } |
| | | } |
| | | |
| | | if err := models.NewOperationSearch().Create(¶ms); err != nil { |
| | | logx.Errorf("Operation create err: %v", err) |
| | | util.ResponseFormat(c, code.SaveFail, "添加失败:"+err.Error()) |
| | |
| | | } |
| | | 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 { |