liujiandao
2024-03-30 952854aaaefaca423c0b87144203551809cb8bdc
proto/product_inventory/server.go
@@ -5,6 +5,7 @@
   "errors"
   "fmt"
   "github.com/shopspring/decimal"
   "gorm.io/gorm"
   "strconv"
   "strings"
   "time"
@@ -466,3 +467,31 @@
   resp.Msg = "success"
   return resp, nil
}
func (s *Server) GetOutputOperationInfo(ctx context.Context, req *GetOutputOperationInfoRequest) (*GetOutputOperationInfoResponse, error) {
   if req.Number == "" {
      return nil, errors.New("参数不能为空")
   }
   result := new(GetOutputOperationInfoResponse)
   first, err := models.NewOperationSearch().SetSourceNumber(req.Number).SetStatus(constvar.OperationStatus_Finish).First()
   if err != nil {
      if err == gorm.ErrRecordNotFound {
         return result, nil
      }
      return nil, err
   }
   details, err := models.NewOperationDetailsSearch().SetOperationId(first.Id).FindNotTotal()
   if err != nil {
      return nil, err
   }
   list := make([]*OutputProduct, 0)
   for _, detail := range details {
      var op OutputProduct
      op.Number = detail.ProductId
      op.Amount = detail.Amount.String()
      list = append(list, &op)
   }
   result.Products = list
   return result, nil
}