jdshop orde

This commit is contained in:
苏尹岚
2020-08-13 11:28:24 +08:00
parent 21a579681f
commit 0980b46796
5 changed files with 47 additions and 34 deletions

View File

@@ -9,25 +9,26 @@ import (
)
type CallBackResult struct {
OrderStateRemark string `json:"orderStateRemark"`
OrderRemark string `json:"orderRemark"`
OrderSellerPrice string `json:"orderSellerPrice"`
OrderState string `json:"orderState"`
OrderType string `json:"orderType"`
OrderPayment string `json:"orderPayment"`
PayType string `json:"payType"`
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"`
MsgType string `json:"msgType"`
Pin string `json:"pin"`
ConsigneeInfo *CallBackConsigneeInfo `json:"consigneeInfo"`
ItemInfoList []*CallBackItemInfoList `json:"itemInfoList"`
OrderStateRemark string `json:"orderStateRemark"`
OrderRemark string `json:"orderRemark"`
OrderSellerPrice string `json:"orderSellerPrice"`
OrderState string `json:"orderState"`
OrderType string `json:"orderType"`
OrderPayment string `json:"orderPayment"`
PayType string `json:"payType"`
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"`
MsgType string `json:"msgType"`
Pin string `json:"pin"`
IDSopShipmenttype string `json:"idSopShipmenttype"`
ConsigneeInfo *CallBackConsigneeInfo `json:"consigneeInfo"`
ItemInfoList []*CallBackItemInfoList `json:"itemInfoList"`
}
type CallBackConsigneeInfo struct {

View File

@@ -6,6 +6,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"strings"
"time"
"git.rosy.net.cn/baseapi/utils"
@@ -221,17 +222,29 @@ func (a *API) KeyGet() (keyGetResult *KeyGetResult, err error) {
return keyGetResult, err
}
type GetOrderExtInfoByOrderIdResult struct {
IDSopShipmentType string `json:"idSopShipmentType"`
OrderCreateDate string `json:"orderCreateDate"`
CodDate string `json:"codDate"`
SelectedItem string `json:"selectedItem"`
Batch string `json:"batch"`
DeliveryCodTime string `json:"deliveryCodTime"`
Speedhour string `json:"Speedhour"`
}
//获取期望送货时间
func (a *API) GetOrderExtInfoByOrderId() (err error) {
_, err = a.AccessAPI("jingdong.pop.order.getOrderExtInfoByOrderId", prodURL, map[string]interface{}{
"orderId": "124162661622",
func (a *API) GetOrderExtInfoByOrderId(orderId string) (time string, err error) {
getOrderExtInfoByOrderIdResult := &GetOrderExtInfoByOrderIdResult{}
result, err := a.AccessAPI("jingdong.pop.order.getOrderExtInfoByOrderId", prodURL, map[string]interface{}{
"orderId": orderId,
"searchFileds": "deliveryInfo",
})
if err == nil {
// data, err2 := base64.StdEncoding.DecodeString(result["jingdong_jos_voucher_info_get_responce"].(map[string]interface{})["response"].(map[string]interface{})["data"].(map[string]interface{})["voucher"].(string))
// if err2 == nil {
// json.Unmarshal(data, &voucherInfoGetResult)
// }
// err = err2
str := strings.ReplaceAll(result["jingdong_pop_order_getOrderExtInfoByOrderId_responce"].(map[string]interface{})["orderExtraInfoResultModel"].(map[string]interface{})["resultMap"].(map[string]interface{})["deliveryInfo"].(string), "\\", "")
err = json.Unmarshal([]byte(str), &getOrderExtInfoByOrderIdResult)
exTime := strings.Split(getOrderExtInfoByOrderIdResult.DeliveryCodTime, ",")
exTime2 := strings.Split(exTime[1], "-")
time = exTime[0] + " " + exTime2[1] + ":00"
}
return err
return time, err
}

View File

@@ -47,9 +47,9 @@ func TestKeyGet(t *testing.T) {
}
func TestGetOrderExtInfoByOrderId(t *testing.T) {
err := api.GetOrderExtInfoByOrderId()
result, err := api.GetOrderExtInfoByOrderId("")
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
t.Log(utils.Format4Output(result, false))
}