From 38e5627134a81c831d4867ef4085b2bda9291b24 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期五, 15 三月 2024 10:40:17 +0800 Subject: [PATCH] 获取信息修改 --- api/v1/salesDetails.go | 110 ------------------------------------------------------- 1 files changed, 0 insertions(+), 110 deletions(-) diff --git a/api/v1/salesDetails.go b/api/v1/salesDetails.go index 9f94f9e..874d2c4 100644 --- a/api/v1/salesDetails.go +++ b/api/v1/salesDetails.go @@ -11,7 +11,6 @@ "aps_crm/pkg/logx" "aps_crm/pkg/structx" "aps_crm/proto/crm_aps" - "aps_crm/proto/crm_srm" "aps_crm/proto/product_inventory" "aps_crm/utils" "github.com/gin-gonic/gin" @@ -385,113 +384,4 @@ return } ctx.Ok() -} - -// GetSalesDetailsProductInfo -// -// @Tags SalesDetails -// @Summary 鑾峰彇閿�鍞槑缁嗕骇鍝佷俊鎭� -// @Produce application/json -// @Param number path string true "鏄庣粏缂栫爜" -// @Success 200 {object} response.ListResponse -// -// @Router /api/salesDetails/getSalesDetailsProductInfo/{number} [get] -func (s *SalesDetailsApi) GetSalesDetailsProductInfo(c *gin.Context) { - ctx, ok := contextx.NewContext(c, nil) - if !ok { - return - } - number := c.Param("number") - first, err := model.NewSalesDetailsSearch().SetPreload(true).SetNumber(number).First() - if err != nil { - ctx.FailWithMsg(ecode.DBErr, "鏌ヨ閿�鍞槑缁嗗嚭閿�") - return - } - resp := make([]response.SalesDetailsProductInfo, 0) - amountMap := make(map[string]int64) - overMap := make(map[string]int64) - for _, product := range first.Products { - amountMap[product.Number] = 0 - overMap[product.Number] = 0 - var sdpi response.SalesDetailsProductInfo - sdpi.ProductId = product.Number - sdpi.ProductName = product.Name - sdpi.Specs = product.Specs - sdpi.Unit = product.Unit - sdpi.Amount = product.Amount - sdpi.Cost = product.Cost - sdpi.Price = product.Price - sdpi.Total = product.Total - sdpi.Profit = product.Profit - sdpi.Margin = product.Margin - resp = append(resp, sdpi) - } - srmClient := crm_srm.NewCrmAndSrmServiceClient(grpc_init.CrmSrmGrpcServiceConn) - info, err := srmClient.CrmGetPurchaseInfo(c, &crm_srm.CrmGetPurchaseInfoRequest{SalesDetailsNumber: number}) - if err != nil { - logx.Errorf("grpc CrmGetPurchaseInfo err: %v", err.Error()) - ctx.FailWithMsg(ecode.UnknownErr, "鍐呴儴閿欒") - return - } - //閲囪喘鏁伴噺 - for _, purchaseInfo := range info.Info { - amount := amountMap[purchaseInfo.ProductId] - amount += purchaseInfo.Amount - amountMap[purchaseInfo.ProductId] = amount - over := overMap[purchaseInfo.ProductId] - over += purchaseInfo.FinishAmount - overMap[purchaseInfo.ProductId] = over - } - for i := 0; i < len(resp); i++ { - resp[i].PurchaseAmount = amountMap[resp[i].ProductId] - amountMap[resp[i].ProductId] = 0 - resp[i].PurchaseFinishAmount = overMap[resp[i].ProductId] - resp[i].FinishAmount = resp[i].FinishAmount + overMap[resp[i].ProductId] - overMap[resp[i].ProductId] = 0 - } - - apsClient := crm_aps.NewCrmAndApsGrpcServiceClient(grpc_init.CrmApsGrpcServiceConn) - productInfo, err := apsClient.CrmGetMakeAndOutsourcingProductInfo(c, &crm_aps.CrmGetMakeAndOutsourcingProductInfoRequest{SalesDetailsNumber: number}) - if err != nil { - logx.Errorf("grpc CrmGetMakeAndOutsourcingProductInfo err: %v", err.Error()) - ctx.FailWithMsg(ecode.UnknownErr, "鍐呴儴閿欒") - return - } - //鍒堕�犳暟閲� - for _, makeInfo := range productInfo.Info { - if makeInfo.Type == 2 { - amount := amountMap[makeInfo.ProductId] - amount += makeInfo.Amount - amountMap[makeInfo.ProductId] = amount - over := overMap[makeInfo.ProductId] - over += makeInfo.FinishAmount - overMap[makeInfo.ProductId] = over - } - } - for i := 0; i < len(resp); i++ { - resp[i].MakeAmount = amountMap[resp[i].ProductId] - amountMap[resp[i].ProductId] = 0 - resp[i].MakeFinishAmount = overMap[resp[i].ProductId] - resp[i].FinishAmount = resp[i].FinishAmount + overMap[resp[i].ProductId] - overMap[resp[i].ProductId] = 0 - } - //濮斿鏁伴噺 - for _, outsourcingInfo := range productInfo.Info { - if outsourcingInfo.Type == 3 { - amount := amountMap[outsourcingInfo.ProductId] - amount += outsourcingInfo.Amount - amountMap[outsourcingInfo.ProductId] = amount - over := overMap[outsourcingInfo.ProductId] - over += outsourcingInfo.FinishAmount - overMap[outsourcingInfo.ProductId] = over - } - } - for i := 0; i < len(resp); i++ { - resp[i].OutsourcingAmount = amountMap[resp[i].ProductId] - amountMap[resp[i].ProductId] = 0 - resp[i].OutsourcingFinishAmount = overMap[resp[i].ProductId] - resp[i].FinishAmount = resp[i].FinishAmount + overMap[resp[i].ProductId] - overMap[resp[i].ProductId] = 0 - } - ctx.OkWithDetailed(resp) } -- Gitblit v1.8.0