From 40e540f8ca398fee68f4520dbebd6db6fe2e164c Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期四, 11 一月 2024 15:28:19 +0800 Subject: [PATCH] 添加销售明细推送到wms --- api/v1/salesDetails.go | 26 ++------------------------ 1 files changed, 2 insertions(+), 24 deletions(-) diff --git a/api/v1/salesDetails.go b/api/v1/salesDetails.go index cab0091..bae4856 100644 --- a/api/v1/salesDetails.go +++ b/api/v1/salesDetails.go @@ -1,7 +1,6 @@ package v1 import ( - "aps_crm/conf" "aps_crm/constvar" "aps_crm/model" "aps_crm/model/grpc_init" @@ -16,8 +15,6 @@ "aps_crm/utils" "github.com/gin-gonic/gin" "github.com/shopspring/decimal" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" "strconv" "strings" ) @@ -240,25 +237,6 @@ ctx.Ok() } -var ( - ProductInventoryServiceConn *grpc.ClientConn -) - -func InitProductInventoryServiceConn() { - var err error - ProductInventoryServiceConn, err = grpc.Dial(conf.Conf.GrpcServiceAddr.WMS, grpc.WithTransportCredentials(insecure.NewCredentials())) - if err != nil { - logx.Errorf("grpc dial product service error: %v", err.Error()) - return - } -} - -func CloseProductInventoryServiceConn() { - if ProductInventoryServiceConn != nil { - ProductInventoryServiceConn.Close() - } -} - // GetProductInventoryInfo // // @Tags SalesDetails @@ -274,7 +252,7 @@ return } number := c.Param("number") - client := product_inventory.NewProductInventoryServiceClient(ProductInventoryServiceConn) + client := product_inventory.NewProductInventoryServiceClient(grpc_init.ProductInventoryServiceConn) info, err := client.GetInventoryProductInfo(ctx.GetCtx(), &product_inventory.GetInventoryProductInfoRequest{Number: number}) if err != nil { if strings.Contains(err.Error(), "record not found") { @@ -358,7 +336,7 @@ p.Amount = product.Amount.String() wmsProducts = append(wmsProducts, &p) } - clientWms := product_inventory.NewProductInventoryServiceClient(ProductInventoryServiceConn) + clientWms := product_inventory.NewProductInventoryServiceClient(grpc_init.ProductInventoryServiceConn) _, err = clientWms.CreateOperation(ctx.GetCtx(), &product_inventory.CreateOperationRequest{ Number: params.Number, Addressee: params.Addressee, -- Gitblit v1.8.0