zhangqian
2024-04-07 d384930963f9b960a06864223aff779edc4cf54c
api/v1/product.go
@@ -9,9 +9,11 @@
   "aps_crm/pkg/ecode"
   "aps_crm/pkg/logx"
   "aps_crm/proto/product"
   "aps_crm/proto/product_inventory"
   "github.com/gin-gonic/gin"
   "github.com/shopspring/decimal"
   "github.com/spf13/cast"
   "strconv"
)
type ProductApi struct{}
@@ -164,6 +166,7 @@
   productInfo := make([]response.SalesDetailsProductInfo, 0)
   amountMap := make(map[string]int64)
   overMap := make(map[string]int64)
   outputMap := make(map[string]int)
   for _, p := range first.Products {
      amountMap[p.Number] = 0
      overMap[p.Number] = 0
@@ -187,6 +190,18 @@
      logx.Errorf("grpc GetProductOrder err: %v", err.Error())
      ctx.FailWithMsg(ecode.UnknownErr, "内部错误")
      return
   }
   //查询发货信息
   cl := product_inventory.NewProductInventoryServiceClient(grpc_init.ProductInventoryServiceConn)
   operationInfo, err := cl.GetOutputOperationInfo(ctx.GetCtx(), &product_inventory.GetOutputOperationInfoRequest{Number: number})
   if err != nil {
      logx.Errorf("grpc GetOutputOperationInfo err: %v", err.Error())
      ctx.FailWithMsg(ecode.UnknownErr, "内部错误")
      return
   }
   for _, outputProduct := range operationInfo.Products {
      amount, _ := strconv.Atoi(outputProduct.Amount)
      outputMap[outputProduct.Number] = amount
   }
   var result response.Info
   //制造信息
@@ -278,6 +293,12 @@
      productInfo[i].FinishAmount = productInfo[i].FinishAmount + overMap[productInfo[i].ProductId]
      overMap[productInfo[i].ProductId] = 0
   }
   //发货信息
   for i := 0; i < len(productInfo); i++ {
      productInfo[i].DeliveryAmount = productInfo[i].DeliveryAmount + outputMap[productInfo[i].ProductId]
   }
   result.OutsourcingInfo = outsourcingList
   result.ProductInfo = productInfo
   ctx.OkWithDetailed(result)