JCQ 2022-04-06

This commit is contained in:
807875765@qq.com
2022-04-06 16:03:29 +08:00
parent 72c0c58e2d
commit 583c9210b5
4 changed files with 80 additions and 2 deletions

View File

@@ -16,8 +16,9 @@ import (
)
const (
sigKey = "signature"
httpURL = "http://jcq-hb-yd-001-httpsrv-nlb-FI.jvessel-open-hb.jdcloud.com:8080"
sigKey = "signature"
httpURL = "http://jcq-hb-yd-001-httpsrv-nlb-FI.jvessel-open-hb.jdcloud.com:8080"
httpURL2 = "http://114.67.73.174:8080/msg"
ConsumerGroupID = "open_message_573819178445" //所有topic都是这个
ConsumerGroupID2 = "open_message_413277234485" //所有topic都是这个
@@ -146,3 +147,16 @@ func (a *API) ConsumeInfo(topic, consumerGroupId string, size int) (consumeInfoR
}
return consumeInfoResult, err
}
func (a *API) ConsumeInfo2(topic, consumerGroupId string, size int) (consumeInfoResult []*ConsumeInfoResult, err error) {
result, err := a.AccessAPI("v2/messages", httpURL2, map[string]interface{}{
"topic": topic,
"consumerGroupId": consumerGroupId,
"size": size,
//"ack": "true", //默认消费之后就确认
})
if err == nil {
utils.Map2StructByJson(result["result"].(map[string]interface{})["messages"], &consumeInfoResult, false)
}
return consumeInfoResult, err
}

View File

@@ -25,3 +25,11 @@ func init() {
func TestConsumeInfo(t *testing.T) {
fmt.Println(utils.Str2Float64("2.60"))
}
func TestAPI_ConsumeInfo2(t *testing.T) {
result, _ := api.ConsumeInfo2("open_message_pop_order_create_E1D746D42474D5F1F1A10CECE75D99F6", "open_message_573819178445", 32)
for _, val := range result {
fmt.Println("")
fmt.Println(val.MessageBody)
}
}

View File

@@ -15,6 +15,7 @@ import (
const (
prodURL = "https://api.jd.com/routerjson"
prodURL2 = "http://114.67.73.174:8080/ask/routerjson"
sigKey = "sign"
JdsImgURL = "//img10.360buyimg.com/imgzone/"
JdsImgDescURL = `<img src=" //img10.360buyimg.com/imgzone/jfs/t1/111969/32/6692/171733/5ebbb9daE5bedb5b2/38350dca19e2b9d2.jpg" style="width: auto; height: auto; max-width: 100%;">`

View File

@@ -0,0 +1,55 @@
package jdshopapi
import "git.rosy.net.cn/baseapi/utils"
//Creat by hang At 2022-03-28
//用于处理获得消息后对于订单的Api调用 jdsOrderApi和jdsOrder2Api分别对应shop_jxcs2021和shop——jxcs2022两个订单 由于api分为两个店铺 因此对一个OrderId查询需要同时引入两个aou
type GetEnOrderResult struct {
OrderStateRemark string `json:"orderStateRemark"`
OrderRemark string `json:"orderRemark"`
OrderSellerPrice string `json:"orderSellerPrice"`
OrderState string `json:"orderState"`
OrderType string `json:"orderType"`
ConsigneeInfo *CallBackConsigneeInfo `json:"consigneeInfo"`
OrderPayment string `json:"orderPayment"`
PayType string `json:"payType"`
ItemInfoList []*CallBackItemInfoList `json:"itemInfoList"`
StoreID string `json:"storeId"`
OrderTotalPrice string `json:"orderTotalPrice"`
OrderExt string `json:"orderExt"`
StoreOrder string `json:"storeOrder"`
OrderStartTime string `json:"orderStartTime"`
OrderID string `json:"orderId"`
OrderSource string `json:"orderSource"`
FreightPrice string `json:"freightPrice"`
Pin string `json:"pin"`
IDSopShipmenttype string `json:"idSopShipmenttype"`
ScDT string `json:"scDT"`
SellerDiscount string `json:"sellerDiscount"`
MenDianID string `json:"menDianId"`
BalanceUsed string `json:"balanceUsed"`
}
//根据订单ID查询订单 京东换了新的接口 原来的接口变为收费接口
//https://open.jd.com/home/home#/doc/api?apiCateId=55&apiId=2366&apiName=jingdong.pop.oto.locorderinfo.enget
//目前消息队列同时订阅2011和2012的账号但是对应的是两个accessToken所以对于一个订单id要先查一个api如果查不到后再查一个api
//另外由于现在的接口对于返回的数据中手机和pin都不支持解密详见工单 手机号已脱敏改造
//https://open.jd.com/home/home#/support/my-ask-detail/17522185
func (a *API) GetOrderById(orderID int64, isStatus bool) (getOrderResult *GetEnOrderResult, err error) {
params := make(map[string]interface{})
params["order_id"] = orderID
params["optional_fields"] = `orderType,payType,orderTotalPrice,orderSellerPrice,
orderPayment,freightPrice,orderState,orderStateRemark,
orderStartTime,orderEndTime,orderRemark,consigneeInfo,
itemInfoList,pauseBizInfo,pin,idSopShipmenttype,scDT,sellerDiscount,menDianId,storeId,balanceUsed,orderExt`
if isStatus {
params["order_state"] = "WAIT_SELLER_STOCK_OUT,TRADE_CANCELED,PAUSE,WAIT_GOODS_RECEIVE_CONFIRM,FINISHED_L"
}
result, err := a.AccessAPI("jingdong.pop.order.enGet", prodURL2, params)
if err == nil {
utils.Map2StructByJson(result["jingdong_pop_order_enGet_responce"].(map[string]interface{})["orderDetailInfo"].(map[string]interface{})["orderInfo"], &getOrderResult, false)
}
return getOrderResult, err
}