From 42ca2293072e5eb011e655c9cc8fd9bf0ba376f1 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期四, 23 十一月 2023 14:42:58 +0800 Subject: [PATCH] 推送销售明细信息到其他系统 --- api/v1/salesDetails.go | 90 ++++++++-------------- router/salesDetails.go | 20 ++-- docs/swagger.yaml | 23 ----- docs/docs.go | 34 -------- docs/swagger.json | 34 -------- 5 files changed, 50 insertions(+), 151 deletions(-) diff --git a/api/v1/salesDetails.go b/api/v1/salesDetails.go index 625e2b6..c1ce33d 100644 --- a/api/v1/salesDetails.go +++ b/api/v1/salesDetails.go @@ -289,53 +289,6 @@ ctx.OkWithDetailed(list) } -// CreateOperation -// -// @Tags SalesDetails -// @Summary 鍒涘缓浜у搧鍑哄簱淇℃伅 -// @Produce application/json -// @Param object body request.SalesDetails true "鏌ヨ鍙傛暟" -// @Success 200 {object} response.ListResponse -// -// @Router /api/salesDetails/createOperation [post] -func (s *SalesDetailsApi) CreateOperation(c *gin.Context) { - var params request.SalesDetails - ctx, ok := contextx.NewContext(c, ¶ms) - if !ok { - return - } - m := make(map[string]interface{}) - m["status"] = params.Status - err := model.NewSalesDetailsSearch().SetNumber(params.Number).UpdateByMap(m) - if err != nil { - ctx.FailWithMsg(ecode.UnknownErr, "鐘舵�佹洿鏂板け璐�") - return - } - - client := product_inventory.NewProductInventoryServiceClient(ProductInventoryServiceConn) - products := make([]*product_inventory.InventoryProduct, 0) - for _, product := range params.Products { - var p product_inventory.InventoryProduct - p.Id = product.Number - p.Amount = product.Amount.String() - products = append(products, &p) - } - _, err = client.CreateOperation(ctx.GetCtx(), &product_inventory.CreateOperationRequest{ - Number: params.Number, - Addressee: params.Addressee, - Address: params.Address, - Phone: params.Phone, - DeliverType: int32(params.DeliverType), - ProductList: products, - }) - if err != nil { - logx.Errorf("CreateOperation err: %v", err.Error()) - ctx.FailWithMsg(ecode.UnknownErr, "grpc璋冪敤閿欒") - return - } - ctx.Ok() -} - // GetApsProjectList // // @Tags SalesDetails @@ -358,16 +311,16 @@ ctx.OkWithDetailed(projectList.List) } -// SendSalesDetailsToApsProject +// SendSalesDetailsToOtherSystem // // @Tags SalesDetails -// @Summary 鎺ㄩ�侀攢鍞槑缁嗕俊鎭埌aps椤圭洰妯″潡 +// @Summary 鎺ㄩ�侀攢鍞槑缁嗕俊鎭埌鍏朵粬绯荤粺 // @Produce application/json // @Param object body request.SalesDetails true "鏌ヨ鍙傛暟" // @Success 200 {object} response.ListResponse // -// @Router /api/salesDetails/sendSalesDetailsToApsProject [post] -func (s *SalesDetailsApi) SendSalesDetailsToApsProject(c *gin.Context) { +// @Router /api/salesDetails/sendSalesDetailsToOtherSystem [post] +func (s *SalesDetailsApi) SendSalesDetailsToOtherSystem(c *gin.Context) { var params request.SalesDetails ctx, ok := contextx.NewContext(c, ¶ms) if !ok { @@ -381,18 +334,40 @@ return } - products := make([]*crm_aps.SalesDetailsProduct, 0) + //鎺ㄩ�佸埌wms + wmsProducts := make([]*product_inventory.InventoryProduct, 0) + for _, product := range params.Products { + var p product_inventory.InventoryProduct + p.Id = product.Number + p.Amount = product.Amount.String() + wmsProducts = append(wmsProducts, &p) + } + clientWms := product_inventory.NewProductInventoryServiceClient(ProductInventoryServiceConn) + _, err = clientWms.CreateOperation(ctx.GetCtx(), &product_inventory.CreateOperationRequest{ + Number: params.Number, + Addressee: params.Addressee, + Address: params.Address, + Phone: params.Phone, + DeliverType: int32(params.DeliverType), + ProductList: wmsProducts, + }) + if err != nil { + logx.Errorf("CreateOperation err: %v", err.Error()) + } + + //鎺ㄩ�佸埌aps + ApsProducts := make([]*crm_aps.SalesDetailsProduct, 0) var total decimal.Decimal for _, product := range params.Products { var sp crm_aps.SalesDetailsProduct sp.ProductId = product.Number sp.Amount = product.Amount.IntPart() - products = append(products, &sp) + ApsProducts = append(ApsProducts, &sp) total = total.Add(product.Amount) } - client := crm_aps.NewCrmAndApsGrpcServiceClient(grpc_init.CrmApsGrpcServiceConn) - _, err = client.SendSalesDetailsToApsProject(c, &crm_aps.SendSalesDetailsToApsProjectRequest{ + clientAps := crm_aps.NewCrmAndApsGrpcServiceClient(grpc_init.CrmApsGrpcServiceConn) + _, err = clientAps.SendSalesDetailsToApsProject(c, &crm_aps.SendSalesDetailsToApsProjectRequest{ Number: params.Number, ClientName: params.Client.Name, MemberName: params.Member.Username, @@ -401,9 +376,12 @@ Source: params.Source, ProductTotal: total.IntPart(), ProjectId: params.ProjectId, - Products: products, + Products: ApsProducts, }) if err != nil { + //鐘舵�佽繕鍘� + m["status"] = constvar.WaitConfirmed + _ = model.NewSalesDetailsSearch().SetNumber(params.Number).UpdateByMap(m) ctx.FailWithMsg(ecode.UnknownErr, "grpc璋冪敤閿欒: "+err.Error()) return } diff --git a/docs/docs.go b/docs/docs.go index d489003..f41e352 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -6971,36 +6971,6 @@ } } }, - "/api/salesDetails/createOperation": { - "post": { - "produces": [ - "application/json" - ], - "tags": [ - "SalesDetails" - ], - "summary": "鍒涘缓浜у搧鍑哄簱淇℃伅", - "parameters": [ - { - "description": "鏌ヨ鍙傛暟", - "name": "object", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.SalesDetails" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.ListResponse" - } - } - } - } - }, "/api/salesDetails/delete": { "delete": { "produces": [ @@ -7148,7 +7118,7 @@ } } }, - "/api/salesDetails/sendSalesDetailsToApsProject": { + "/api/salesDetails/sendSalesDetailsToOtherSystem": { "post": { "produces": [ "application/json" @@ -7156,7 +7126,7 @@ "tags": [ "SalesDetails" ], - "summary": "鎺ㄩ�侀攢鍞槑缁嗕俊鎭埌aps椤圭洰妯″潡", + "summary": "鎺ㄩ�侀攢鍞槑缁嗕俊鎭埌鍏朵粬绯荤粺", "parameters": [ { "description": "鏌ヨ鍙傛暟", diff --git a/docs/swagger.json b/docs/swagger.json index 7bec273..349a879 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -6959,36 +6959,6 @@ } } }, - "/api/salesDetails/createOperation": { - "post": { - "produces": [ - "application/json" - ], - "tags": [ - "SalesDetails" - ], - "summary": "鍒涘缓浜у搧鍑哄簱淇℃伅", - "parameters": [ - { - "description": "鏌ヨ鍙傛暟", - "name": "object", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.SalesDetails" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.ListResponse" - } - } - } - } - }, "/api/salesDetails/delete": { "delete": { "produces": [ @@ -7136,7 +7106,7 @@ } } }, - "/api/salesDetails/sendSalesDetailsToApsProject": { + "/api/salesDetails/sendSalesDetailsToOtherSystem": { "post": { "produces": [ "application/json" @@ -7144,7 +7114,7 @@ "tags": [ "SalesDetails" ], - "summary": "鎺ㄩ�侀攢鍞槑缁嗕俊鎭埌aps椤圭洰妯″潡", + "summary": "鎺ㄩ�侀攢鍞槑缁嗕俊鎭埌鍏朵粬绯荤粺", "parameters": [ { "description": "鏌ヨ鍙傛暟", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 0d7524a..853f908 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -10657,25 +10657,6 @@ summary: 娣诲姞閿�鍞槑缁� tags: - SalesDetails - /api/salesDetails/createOperation: - post: - parameters: - - description: 鏌ヨ鍙傛暟 - in: body - name: object - required: true - schema: - $ref: '#/definitions/request.SalesDetails' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.ListResponse' - summary: 鍒涘缓浜у搧鍑哄簱淇℃伅 - tags: - - SalesDetails /api/salesDetails/delete: delete: parameters: @@ -10767,7 +10748,7 @@ summary: 閿�鍞槑缁嗗崟鍒楄〃 tags: - SalesDetails - /api/salesDetails/sendSalesDetailsToApsProject: + /api/salesDetails/sendSalesDetailsToOtherSystem: post: parameters: - description: 鏌ヨ鍙傛暟 @@ -10783,7 +10764,7 @@ description: OK schema: $ref: '#/definitions/response.ListResponse' - summary: 鎺ㄩ�侀攢鍞槑缁嗕俊鎭埌aps椤圭洰妯″潡 + summary: 鎺ㄩ�侀攢鍞槑缁嗕俊鎭埌鍏朵粬绯荤粺 tags: - SalesDetails /api/salesDetails/update: diff --git a/router/salesDetails.go b/router/salesDetails.go index 7da3a2d..7d7db0c 100644 --- a/router/salesDetails.go +++ b/router/salesDetails.go @@ -11,15 +11,15 @@ salesDetailsRouter := router.Group("salesDetails") salesDetailsApi := v1.ApiGroup.SalesDetailsApi { - salesDetailsRouter.POST("add", salesDetailsApi.Add) // 娣诲姞閿�鍞槑缁� - salesDetailsRouter.DELETE("delete/:id", salesDetailsApi.Delete) // 鍒犻櫎閿�鍞槑缁� - salesDetailsRouter.DELETE("delete", salesDetailsApi.BatchDelete) // 鎵归噺鍒犻櫎閿�鍞槑缁� - salesDetailsRouter.PUT("update", salesDetailsApi.Update) // 鏇存柊閿�鍞槑缁� - salesDetailsRouter.POST("updateStatus", salesDetailsApi.UpdateStatus) // 鏇存柊閿�鍞槑缁嗙姸鎬� - salesDetailsRouter.POST("list", salesDetailsApi.List) // 鑾峰彇閿�鍞槑缁嗗崟鍒楄〃 - salesDetailsRouter.GET("getProductInventoryInfo/:number", salesDetailsApi.GetProductInventoryInfo) // 鑾峰彇浜у搧搴撳瓨淇℃伅 - salesDetailsRouter.POST("createOperation", salesDetailsApi.CreateOperation) // 鍒涘缓浜у搧鍑哄簱淇℃伅 - salesDetailsRouter.GET("getApsProjectList", salesDetailsApi.GetApsProjectList) // 鑾峰彇aps椤圭洰鍒楄〃 - salesDetailsRouter.POST("sendSalesDetailsToApsProject", salesDetailsApi.SendSalesDetailsToApsProject) // 鎺ㄩ�侀攢鍞槑缁嗕俊鎭埌aps椤圭洰妯″潡 // 鍒涘缓浜у搧鍑哄簱淇℃伅 + salesDetailsRouter.POST("add", salesDetailsApi.Add) // 娣诲姞閿�鍞槑缁� + salesDetailsRouter.DELETE("delete/:id", salesDetailsApi.Delete) // 鍒犻櫎閿�鍞槑缁� + salesDetailsRouter.DELETE("delete", salesDetailsApi.BatchDelete) // 鎵归噺鍒犻櫎閿�鍞槑缁� + salesDetailsRouter.PUT("update", salesDetailsApi.Update) // 鏇存柊閿�鍞槑缁� + salesDetailsRouter.POST("updateStatus", salesDetailsApi.UpdateStatus) // 鏇存柊閿�鍞槑缁嗙姸鎬� + salesDetailsRouter.POST("list", salesDetailsApi.List) // 鑾峰彇閿�鍞槑缁嗗崟鍒楄〃 + salesDetailsRouter.GET("getProductInventoryInfo/:number", salesDetailsApi.GetProductInventoryInfo) // 鑾峰彇浜у搧搴撳瓨淇℃伅 + //salesDetailsRouter.POST("createOperation", salesDetailsApi.CreateOperation) // 鍒涘缓浜у搧鍑哄簱淇℃伅 + salesDetailsRouter.GET("getApsProjectList", salesDetailsApi.GetApsProjectList) // 鑾峰彇aps椤圭洰鍒楄〃 + salesDetailsRouter.POST("sendSalesDetailsToOtherSystem", salesDetailsApi.SendSalesDetailsToOtherSystem) // 鎺ㄩ�侀攢鍞槑缁嗕俊鎭埌鍏朵粬绯荤粺 // 鍒涘缓浜у搧鍑哄簱淇℃伅 } } -- Gitblit v1.8.0