| | |
| | | } |
| | | |
| | | params.Status = constvar.OperationStatus_Ready |
| | | params.Number = strconv.FormatInt(time.Now().Unix(), 10) |
| | | //params.Number = strconv.FormatInt(time.Now().Unix(), 10) |
| | | params.BaseOperationType = operationType.BaseOperationType |
| | | |
| | | 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 |
| | | } |
| | | |
| | | 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("请填入源单号") |
| | | } |
| | | |
| | | if params.Number == "" { |
| | | return errors.New("请填入单号") |
| | | } |
| | | |
| | | if params.OperationTypeId == 0 && int(params.BaseOperationType) == 0 { |
| | | return errors.New("未识别该记录类型") |
| | | } |