From a71f902289ab6d37e3e3c8a1ab9fc6a04ab6c0bb 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, 3 Jun 2020 11:18:16 +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=95=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/jdshopapi/order.go | 24 ++++++++++++++---------- platformapi/jdshopapi/order_test.go | 2 +- platformapi/jdshopapi/store_page.go | 2 +- platformapi/jdshopapi/store_page_test.go | 5 ----- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/platformapi/jdshopapi/order.go b/platformapi/jdshopapi/order.go index 3eedd452..2c7f591c 100644 --- a/platformapi/jdshopapi/order.go +++ b/platformapi/jdshopapi/order.go @@ -1,15 +1,19 @@ package jdshopapi -//查询单个订单 -//https://open.jd.com/home/home#/doc/api?apiCateId=55&apiId=2389&apiName=jingdong.pop.order.enGet -func (a *API) EnGet(orderID int64) (err error) { - // dataMap := map[string]interface{}{ - // "order_id": orderID, - // "optional_fields": "orderType,payType", - // } - // data, _ := json.Marshal(dataMap) - _, err = a.AccessAPI("jingdong.pop.order.shipment", prodURL, map[string]interface{}{ - "orderId": orderID, +import "fmt" + +//订单出库 +//https://open.jd.com/home/home#/doc/api?apiCateId=55&apiId=1948&apiName=jingdong.pop.order.shipment +func (a *API) OrderShipment(orderID int64, logiCoprId, logiNo string) (err error) { + result, err := a.AccessAPI("jingdong.pop.order.shipment", prodURL, map[string]interface{}{ + "orderId": orderID, + "logiCoprId": logiCoprId, + "logiNo": logiNo, }) + if err == nil { + if !result["jingdong_pop_order_shipment_responce"].(map[string]interface{})["sopjosshipment_result"].(map[string]interface{})["success"].(bool) { + return fmt.Errorf("OrderShipment error: %v", result["jingdong_pop_order_shipment_responce"].(map[string]interface{})["sopjosshipment_result"].(map[string]interface{})["chineseErrCode"]) + } + } return err } diff --git a/platformapi/jdshopapi/order_test.go b/platformapi/jdshopapi/order_test.go index 8c02a36d..6d586eb2 100644 --- a/platformapi/jdshopapi/order_test.go +++ b/platformapi/jdshopapi/order_test.go @@ -5,7 +5,7 @@ import ( ) func TestEnGet(t *testing.T) { - err := api.EnGet(116925931738) + err := api.OrderShipment(1, "logiCoprId", "logiNo") if err != nil { t.Fatal(err) } diff --git a/platformapi/jdshopapi/store_page.go b/platformapi/jdshopapi/store_page.go index a258bfab..eae0ad87 100644 --- a/platformapi/jdshopapi/store_page.go +++ b/platformapi/jdshopapi/store_page.go @@ -418,7 +418,7 @@ func (a *API) OrderDetail(orderId string) (orderDetailResult *OrderDetailResult, } if len(expectedDeliveredTime) > 0 { times := strings.Split(expectedDeliveredTime[1], ",") - orderDetailResult.ExpectedDeliveredTime = times[0] + " " + times[1][:strings.Index(times[1], ":")] + ":30:00" + orderDetailResult.ExpectedDeliveredTime = times[0] + " " + times[1][:strings.Index(times[1], ":")] + ":00:00" } if len(actualPayPrice) > 0 { orderDetailResult.ActualPayPrice = utils.Float64TwoInt64(utils.Str2Float64(strings.TrimSpace(actualPayPrice[1])) * 100) diff --git a/platformapi/jdshopapi/store_page_test.go b/platformapi/jdshopapi/store_page_test.go index 352e1e55..147198d4 100644 --- a/platformapi/jdshopapi/store_page_test.go +++ b/platformapi/jdshopapi/store_page_test.go @@ -73,8 +73,3 @@ func TestOrderDetail(t *testing.T) { } t.Log(utils.Format4Output(result, false)) } - -func TestCC(t *testing.T) { - fmt.Println(utils.Str2Float64("14.00 - ")) -}