diff --git a/platformapi/jcqapi/jcqapi.go b/platformapi/jcqapi/jcqapi.go index 4efdbe39..daa98898 100644 --- a/platformapi/jcqapi/jcqapi.go +++ b/platformapi/jcqapi/jcqapi.go @@ -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 +} diff --git a/platformapi/jcqapi/jcqapi_test.go b/platformapi/jcqapi/jcqapi_test.go index 509d4e54..807d0bd3 100644 --- a/platformapi/jcqapi/jcqapi_test.go +++ b/platformapi/jcqapi/jcqapi_test.go @@ -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) + } +} diff --git a/platformapi/jdshopapi/jdshopapi.go b/platformapi/jdshopapi/jdshopapi.go index e7026399..e78c19b9 100644 --- a/platformapi/jdshopapi/jdshopapi.go +++ b/platformapi/jdshopapi/jdshopapi.go @@ -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 = `` diff --git a/platformapi/jdshopapi/order2.go b/platformapi/jdshopapi/order2.go new file mode 100644 index 00000000..2a4f68c0 --- /dev/null +++ b/platformapi/jdshopapi/order2.go @@ -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 +}