From a536602cb7a37d9a907fa339c39f7c44e51b593c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 22 Jul 2020 16:26:08 +0800 Subject: [PATCH] =?UTF-8?q?jcqresult=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/jcqapi/jcqapi.go | 43 ++++++++++++++++++++++++------- platformapi/jdshopapi/callback.go | 7 +---- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/platformapi/jcqapi/jcqapi.go b/platformapi/jcqapi/jcqapi.go index c5049fb5..ec4a886e 100644 --- a/platformapi/jcqapi/jcqapi.go +++ b/platformapi/jcqapi/jcqapi.go @@ -16,12 +16,33 @@ import ( ) const ( - sigKey = "signature" - + sigKey = "signature" httpURL = "http://jcq-hb-yd-001-httpsrv-nlb-FI.jvessel-open-hb.jdcloud.com:8080" - TopicCreateOrder = "open_message_pop_order_create_E1D746D42474D5F1F1A10CECE75D99F6" - ConsumerGroupIdCreateOrder = "open_message_573819178445" + ConsumerGroupID = "open_message_573819178445" //所有topic都是这个 + TopicSuffix = "_E1D746D42474D5F1F1A10CECE75D99F6" + + TopicRemkChg = "open_message_pop_order_remk_chg" //POP订单备注变更 + TopicOrderOut = "open_message_pop_order_out" //POP订单出库 + TopicOrderCreate = "open_message_pop_order_create" //POP订单创建 + TopicOrderChange = "open_message_pop_order_change" //POP订单变更消息 + TopicOrderPay = "open_message_order_order_pay" //订单付款 + TopicOrderFinish = "open_message_order_order_finish" //订单完成 + TopicOrderCancel = "open_message_order_order_cancel" //订单取消 + + Size = 10 //默认一次取10条 +) + +var ( + TopicList = []string{ + "open_message_pop_order_remk_chg", //POP订单备注变更 + "open_message_pop_order_out", //POP订单出库 + "open_message_pop_order_create", //POP订单创建 + "open_message_pop_order_change", //POP订单变更消息 + "open_message_order_order_pay", //订单付款 + "open_message_order_order_finish", //订单完成 + "open_message_order_order_cancel", //订单取消 + } ) type API struct { @@ -101,20 +122,24 @@ func (a *API) AccessAPI(action string, url string, bizParams map[string]interfac } type ConsumeInfoResult struct { - RequestID string `json:"requestId"` - Result string `json:"result"` + MessageID string `json:"messageId"` + MessageBody string `json:"messageBody"` + Properties struct { + BUSINESSID string `json:"BUSINESS_ID"` + PROPERTYRETRYTIMES string `json:"PROPERTY_RETRY_TIMES"` + } `json:"properties"` } //消费信息 //https://docs.jdcloud.com/cn/message-queue/consume-message -func (a *API) ConsumeInfo(topic, consumerGroupId string) (consumeInfoResult *ConsumeInfoResult, err error) { +func (a *API) ConsumeInfo(topic, consumerGroupId string, size int) (consumeInfoResult *ConsumeInfoResult, err error) { result, err := a.AccessAPI("v1/messages", httpURL, map[string]interface{}{ "topic": topic, "consumerGroupId": consumerGroupId, - "size": 1, + "size": size, }) if err == nil { - utils.Map2StructByJson(result, &consumeInfoResult, false) + utils.Map2StructByJson(result["result"].(map[string]interface{})["messages"], &consumeInfoResult, false) } return consumeInfoResult, err } diff --git a/platformapi/jdshopapi/callback.go b/platformapi/jdshopapi/callback.go index f03f3492..6319b44e 100644 --- a/platformapi/jdshopapi/callback.go +++ b/platformapi/jdshopapi/callback.go @@ -8,12 +8,7 @@ import ( ) type CallBackResult struct { - OrderCreateTime string `json:"orderCreateTime"` - OrderType string `json:"orderType"` - OrderPaymentType string `json:"orderPaymentType"` - VenderID string `json:"venderId"` - OrderStatus string `json:"orderStatus"` - OrderID string `json:"orderId"` + GetOrderResult } func (a *API) GetCallbackMsg(request *http.Request) (call *CallBackResult, err error) {