From 1e65185f0ecb8d4f8f1fd9ea822137e0c841a47f Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期六, 30 三月 2024 17:30:38 +0800 Subject: [PATCH] crm获取发货数量 --- api/v1/product.go | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/api/v1/product.go b/api/v1/product.go index a61ea18..c3aeedd 100644 --- a/api/v1/product.go +++ b/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) -- Gitblit v1.8.0