jiangshuai
2023-09-27 1444c7c800fc042cd99213e901d6ad3722d0f03f
controllers/product_controller.go
@@ -76,7 +76,7 @@
   if params.PageInfo.Check() {
      search.SetPage(params.Page, params.PageSize)
   }
   products, total, err := search.SetKeyword(params.KeyWord).SetOrder("created_at desc").Find()
   products, total, err := search.SetKeyword(params.KeyWord).SetCategoryId(params.CategoryId).SetOrder("created_at desc").Find()
   if err != nil {
      util.ResponseFormat(c, code.RequestParamError, "查找失败")
      return
@@ -359,20 +359,19 @@
      return
   }
   detail := &models.OperationDetails{
      ProductId:   params.ProductId,
      ProductName: params.ProductName,
      Amount:      params.Amount,
      Unit:        params.Unit,
      ProductId: params.ProductId,
      Amount:    params.Amount,
   }
   operation := models.Operation{
      Number:          strconv.FormatInt(time.Now().Unix(), 10),
      SourceNumber:    params.SourceNumber,
      OperationTypeId: 0,
      Status:          constvar.OperationStatus_Ready,
      FromLocationID:  params.FromLocationId,
      ToLocationID:    params.ToLocationId,
      OperationDate:   time.Now().Format("2006-01-02 15:04:05"),
      Details:         []*models.OperationDetails{detail},
      Number:            strconv.FormatInt(time.Now().Unix(), 10),
      SourceNumber:      params.SourceNumber,
      OperationTypeId:   0,
      Status:            constvar.OperationStatus_Ready,
      FromLocationID:    params.FromLocationId,
      ToLocationID:      params.ToLocationId,
      OperationDate:     time.Now().Format("2006-01-02 15:04:05"),
      Details:           []*models.OperationDetails{detail},
      BaseOperationType: constvar.BaseOperationTypeDisuse,
   }
   if err := models.NewOperationSearch().Create(&operation); err != nil {
      logx.Errorf("Operation create err: %v", err)
@@ -400,7 +399,9 @@
      return
   }
   db := models.NewOperationSearch().Orm.Table("wms_operation").Select("wms_operation.id,wms_operation.number,wms_operation.source_number,wms_operation.status,wms_operation.from_location_id,wms_operation.to_location_id,wms_operation.operation_date,wms_operation.contacter_id,wms_operation.contacter_name,wms_operation.company_id,wms_operation.company_name,wms_operation.comment,wms_operation_details.product_id,wms_operation_details.product_name,wms_operation_details.unit,wms_operation_details.amount").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id")
   //db := models.NewOperationSearch().Orm.Table("wms_operation").Select("wms_operation.id,wms_operation.number,wms_operation.source_number,wms_operation.status,wms_operation.from_location_id,wms_operation.to_location_id,wms_operation.operation_date,wms_operation.contacter_id,wms_operation.contacter_name,wms_operation.company_id,wms_operation.company_name,wms_operation.comment,wms_operation_details.product_id,wms_operation_details.product_name,wms_operation_details.unit,wms_operation_details.amount").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id")
   db := models.NewOperationSearch().Orm.Table("wms_operation").Select("wms_operation.id,wms_operation.number,wms_operation.source_number,wms_operation.status,wms_operation.from_location_id,wms_operation.to_location_id,wms_operation.operation_date,wms_operation.contacter_id,wms_operation.contacter_name,wms_operation.company_id,wms_operation.company_name,wms_operation.comment,wms_operation_details.product_id,material.name as product_name,material.unit,wms_operation_details.amount").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").InnerJoins("inner join material on material.id=wms_operation_details.product_id")
   if params.SourceNumber != "" {
      db = db.Where("wms_operation.source_number like ?", fmt.Sprintf("%%%v%%", params.SourceNumber))
@@ -531,10 +532,10 @@
      return
   }
   detail := &models.OperationDetails{
      ProductId:   params.ProductId,
      ProductName: params.ProductName,
      Amount:      params.Amount,
      Unit:        params.Unit,
      ProductId: params.ProductId,
      //ProductName: params.ProductName,
      Amount: params.Amount,
      //Unit:        params.Unit,
   }
   operation := models.Operation{
      Id:              params.Id,