From f294d50a08d5c1084fe9e16b2d1b666143c5ce67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 13 Aug 2020 16:48:03 +0800 Subject: [PATCH] yujishijian --- platformapi/jdshopapi/order.go | 23 ++++++++++++++--------- platformapi/jdshopapi/order_test.go | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) 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) }