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

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