| | |
| | | } |
| | | util.ResponseFormat(c, code.Success, companies) |
| | | } |
| | | |
| | | // Cancel |
| | | // |
| | | // @Tags 入库/出库 |
| | | // @Summary 取消 |
| | | // @Produce application/json |
| | | // @Param id path int true "id" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/operation/cancel/{id} [put] |
| | | func (slf OperationController) Cancel(c *gin.Context) { |
| | | id, err := strconv.Atoi(c.Param("id")) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "错误的id值") |
| | | return |
| | | } |
| | | if id == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "id为0") |
| | | return |
| | | } |
| | | operation, err := models.NewOperationSearch().SetPreload(true).SetID(id).First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "未找到相关出入库信息:"+err.Error()) |
| | | return |
| | | } |
| | | if operation.Status != constvar.OperationStatus_Ready { |
| | | util.ResponseFormat(c, code.RequestError, "该出入库信息无法取消") |
| | | return |
| | | } |
| | | operation.Status = constvar.OperationStatus_Cancel |
| | | if err := models.NewOperationSearch().Save(operation); err != nil { |
| | | util.ResponseFormat(c, code.SaveFail, err.Error()) |
| | | return |
| | | } |
| | | util.ResponseFormat(c, code.Success, "操作成功") |
| | | } |