diff --git a/platformapi/jdshopapi/order.go b/platformapi/jdshopapi/order.go index bd6156f5..fec13e2b 100644 --- a/platformapi/jdshopapi/order.go +++ b/platformapi/jdshopapi/order.go @@ -223,13 +223,14 @@ func (a *API) KeyGet() (keyGetResult *KeyGetResult, err error) { } 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"` + 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"` + FinalDelieveredTime string `json:"finalDelieveredTime"` } //获取期望送货时间 @@ -243,8 +244,12 @@ func (a *API) GetOrderExtInfoByOrderId(orderId string) (time string, err error) 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" + if len(exTime) < 2 { + time = getOrderExtInfoByOrderIdResult.FinalDelieveredTime + } else { + exTime2 := strings.Split(exTime[1], "-") + time = exTime[0] + " " + exTime2[1] + ":00" + } } return time, err } diff --git a/platformapi/jdshopapi/order_test.go b/platformapi/jdshopapi/order_test.go index 8cdc8efd..c1ec31f2 100644 --- a/platformapi/jdshopapi/order_test.go +++ b/platformapi/jdshopapi/order_test.go @@ -47,7 +47,7 @@ func TestKeyGet(t *testing.T) { } func TestGetOrderExtInfoByOrderId(t *testing.T) { - result, err := api.GetOrderExtInfoByOrderId("") + result, err := api.GetOrderExtInfoByOrderId("130427633633") if err != nil { t.Fatal(err) }