jcqresult修改

This commit is contained in:
苏尹岚
2020-07-22 16:26:08 +08:00
parent 6926d07bed
commit a536602cb7
2 changed files with 35 additions and 15 deletions

View File

@@ -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
}

View File

@@ -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) {