From a62b19d1dbab73ca919e3908fc8f54f7e8999aae 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 14:39:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=AC=E4=B8=9C=E5=95=86=E5=9F=8E=E8=AE=A2?= =?UTF-8?q?=E5=8D=95result?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/jdshopapi/order.go | 114 ++++++++++++++++----------------- 1 file changed, 56 insertions(+), 58 deletions(-) diff --git a/platformapi/jdshopapi/order.go b/platformapi/jdshopapi/order.go index aace085e..76e142c2 100644 --- a/platformapi/jdshopapi/order.go +++ b/platformapi/jdshopapi/order.go @@ -44,67 +44,62 @@ func (a *API) GetDeliveryCompany() (result interface{}, err error) { } type GetOrderResult struct { - JingdongPopOrderGetResponce struct { - Code string `json:"code"` - OrderDetailInfo struct { - OrderInfo struct { - OrderStateRemark string `json:"orderStateRemark"` - OrderRemark string `json:"orderRemark"` - OrderSellerPrice string `json:"orderSellerPrice"` - OrderState string `json:"orderState"` - OrderType string `json:"orderType"` - ConsigneeInfo struct { - ProvinceID string `json:"provinceId"` - FullAddress string `json:"fullAddress"` - CityID string `json:"cityId"` - TownID string `json:"townId"` - City string `json:"city"` - County string `json:"county"` - Province string `json:"province"` - Town string `json:"town"` - Telephone string `json:"telephone"` - Fullname string `json:"fullname"` - CountyID string `json:"countyId"` - Mobile string `json:"mobile"` - } `json:"consigneeInfo"` - OrderPayment string `json:"orderPayment"` - PayType string `json:"payType"` - ItemInfoList []struct { - ProductNo string `json:"productNo"` - ItemTotal string `json:"itemTotal"` - JdPrice string `json:"jdPrice"` - SkuName string `json:"skuName"` - InvoiceContentID string `json:"invoiceContentId"` - ItemExt string `json:"itemExt"` - NewStoreID string `json:"newStoreId"` - OuterSkuID string `json:"outerSkuId"` - SkuID string `json:"skuId"` - WareID string `json:"wareId"` - GiftPoint string `json:"giftPoint"` - } `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"` - } `json:"orderInfo"` - APIResult struct { - EnglishErrCode string `json:"englishErrCode"` - Success bool `json:"success"` - ChineseErrCode string `json:"chineseErrCode"` - NumberCode int `json:"numberCode"` - } `json:"apiResult"` - } `json:"orderDetailInfo"` - } `json:"jingdong_pop_order_get_responce"` + OrderInfo struct { + OrderStateRemark string `json:"orderStateRemark"` + OrderRemark string `json:"orderRemark"` + OrderSellerPrice string `json:"orderSellerPrice"` + OrderState string `json:"orderState"` + OrderType string `json:"orderType"` + ConsigneeInfo struct { + ProvinceID string `json:"provinceId"` + FullAddress string `json:"fullAddress"` + CityID string `json:"cityId"` + TownID string `json:"townId"` + City string `json:"city"` + County string `json:"county"` + Province string `json:"province"` + Town string `json:"town"` + Telephone string `json:"telephone"` + Fullname string `json:"fullname"` + CountyID string `json:"countyId"` + Mobile string `json:"mobile"` + } `json:"consigneeInfo"` + OrderPayment string `json:"orderPayment"` + PayType string `json:"payType"` + ItemInfoList []struct { + ProductNo string `json:"productNo"` + ItemTotal string `json:"itemTotal"` + JdPrice string `json:"jdPrice"` + SkuName string `json:"skuName"` + InvoiceContentID string `json:"invoiceContentId"` + ItemExt string `json:"itemExt"` + NewStoreID string `json:"newStoreId"` + OuterSkuID string `json:"outerSkuId"` + SkuID string `json:"skuId"` + WareID string `json:"wareId"` + GiftPoint string `json:"giftPoint"` + } `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"` + } `json:"orderInfo"` + APIResult struct { + EnglishErrCode string `json:"englishErrCode"` + Success bool `json:"success"` + ChineseErrCode string `json:"chineseErrCode"` + NumberCode int `json:"numberCode"` + } `json:"apiResult"` } //查询单个订单 //https://open.jd.com/home/home#/doc/api?apiCateId=55&apiId=4247&apiName=jingdong.pop.order.get -func (a *API) GetOrder(orderID int64) (err error) { - _, err = a.AccessAPI("jingdong.pop.order.get", prodURL, map[string]interface{}{ +func (a *API) GetOrder(orderID int64) (getOrderResult *GetOrderResult, err error) { + result, err := a.AccessAPI("jingdong.pop.order.get", prodURL, map[string]interface{}{ "order_id": orderID, "optional_fields": `orderType,payType,orderTotalPrice,orderSellerPrice, orderPayment,freightPrice,orderState,orderStateRemark, @@ -112,7 +107,10 @@ func (a *API) GetOrder(orderID int64) (err error) { itemInfoList,pauseBizInfo`, "order_state": "WAIT_SELLER_STOCK_OUT,PAUSE", }) - return err + if err == nil { + utils.Map2StructByJson(result["jingdong_pop_order_get_responce"].(map[string]interface{})["orderDetailInfo"].(map[string]interface{})["orderInfo"], &getOrderResult, false) + } + return getOrderResult, err } type VoucherInfoGetResult struct {