jiangshuai
2023-11-14 76c74cf71fb82099e134cea6a34019655fed2f3f
controllers/operation.go
@@ -1,6 +1,7 @@
package controllers
import (
   "context"
   "encoding/json"
   "errors"
   "fmt"
@@ -684,7 +685,7 @@
      return
   }
   if operation.SourceNumber != "" {
      go UpdateSalesDetailStatus(c, operation.SourceNumber)
      go UpdateSalesDetailStatus(operation.SourceNumber)
   }
   util.ResponseFormat(c, code.Success, "操作成功")
}
@@ -706,9 +707,9 @@
   }
}
func UpdateSalesDetailStatus(ctx *gin.Context, number string) {
func UpdateSalesDetailStatus(number string) {
   client := product_inventory.NewProductInventoryServiceClient(ProductInventoryServiceConn)
   _, err := client.UpdateSalesDetailStatus(ctx, &product_inventory.UpdateSalesDetailStatusRequest{
   _, err := client.UpdateSalesDetailStatus(context.Background(), &product_inventory.UpdateSalesDetailStatusRequest{
      Number:            number,
      SalesDetailStatus: "已出库",
   })
@@ -762,3 +763,38 @@
   }
   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().SetID(operation.Id).Save(operation); err != nil {
      util.ResponseFormat(c, code.SaveFail, err.Error())
      return
   }
   util.ResponseFormat(c, code.Success, "操作成功")
}