From 798c5fcaf852920d435287c631cf3c4cd501684c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 30 Mar 2022 17:34:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E8=B0=83=E6=89=93=E6=A1=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/fnpsapi/fn_test.go | 55 +++++++++++++++++++++------- platformapi/fnpsapi/fnps_v3.go | 18 +++++---- platformapi/fnpsapi/store.go | 3 +- platformapi/fnpsapi_v3/order_test.go | 31 ---------------- 4 files changed, 54 insertions(+), 53 deletions(-) diff --git a/platformapi/fnpsapi/fn_test.go b/platformapi/fnpsapi/fn_test.go index 2ab717dd..30df5222 100644 --- a/platformapi/fnpsapi/fn_test.go +++ b/platformapi/fnpsapi/fn_test.go @@ -13,6 +13,47 @@ func Init() { api.accessToken = token.BusinessDataObj.AccessToken } +// 查询单个门店 +func TestQueryOneStore(t *testing.T) { + api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691", "") + token, err := api.GetAccessToken() + api.accessToken = token.BusinessDataObj.AccessToken + data, err := api.GetStore("209476483") + fmt.Println(data) + fmt.Println(err) +} + +// 正式下单 +func TestCreateOrder(t *testing.T) { + api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691", "") + token, _ := api.GetAccessToken() + api.accessToken = token.BusinessDataObj.AccessToken + + aa := []*GoodsItemsList{ + {"白菜", 1, 100, 100, "30011", 1, "备注:大白菜"}, + //{"白菜2", 1, 100, 100, "30012", 1, "备注:大白菜2"}, + // {"白菜3", 1, 100, 100, "1004", 1, "备注:大白菜2"}, + } + err := api.CreateOrder(&CreateOrderReqParam{ + PartnerOrderCode: "232232999uue21", + OrderType: 1, + PositionSource: 3, + ReceiverAddress: "四川成都", + ReceiverLongitude: 116.307892, + ReceiverLatitude: 40.039115, + GoodsTotalAmountCent: 100, + GoodsActualAmountCent: 100, + GoodsWeight: 0.25, + GoodsCount: 1, + GoodsItemList: aa, + ReceiverName: "刘磊", + ReceiverPrimaryPhone: "18981810340", + OutShopCode: "", + ChainStoreId: "209476483", + }) + fmt.Println(err) +} + // 创建门店, func TestCreateStore(t *testing.T) { api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691", "cabrXQf9eFMVWVYg4hNlwu") @@ -54,7 +95,7 @@ func TestUpdataStore(t *testing.T) { token, _ := api.GetAccessToken() api.accessToken = token.BusinessDataObj.AccessToken err := api.UpdateStore(&UpdateStoreParam{ - ChainStoreID: "209636747", + ChainStoreID: 209636747, HeadShopName: "刘磊测试门店", ContactPhone: "18981810340", Address: "四川成都", @@ -91,18 +132,6 @@ func TestClient(t *testing.T) { fmt.Println("err=====", err) } -// 查询单个门店 -func TestQueryOneStore(t *testing.T) { - api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "51658", "4W4hqacKND6NOct5gCyjbT") - token, err := api.GetAccessToken() - fmt.Println("err! ========", err) - api.accessToken = token.BusinessDataObj.AccessToken - fmt.Println("err! ========accessToken", api.accessToken) - data, err := api.GetStore("637910") - fmt.Println(data) - fmt.Println(err) -} - // 预下单 func TestGetOrder(t *testing.T) { api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691", "") diff --git a/platformapi/fnpsapi/fnps_v3.go b/platformapi/fnpsapi/fnps_v3.go index ca2e5905..57dc326d 100644 --- a/platformapi/fnpsapi/fnps_v3.go +++ b/platformapi/fnpsapi/fnps_v3.go @@ -7,13 +7,13 @@ import ( ) const ( - TokenURL = "https://open-anubis.ele.me/anubis-webapi/openapi/token" // 正式环境 - ApiURL = "https://open-anubis.ele.me/anubis-webapi/v3/invoke" // 正式环境 + //TokenURL = "https://open-anubis.ele.me/anubis-webapi/openapi/token" // 正式环境 + //ApiURL = "https://open-anubis.ele.me/anubis-webapi/v3/invoke" // 正式环境 RefreshTokenUrl = "https://open-anubis.ele.me/anubis-webapi/openapi/refreshToken" // 正式环境刷新token - //TokenURL = "https://exam-anubis.ele.me/anubis-webapi/openapi/token" // 沙箱环境 - //ApiURL = "https://exam-anubis.ele.me/anubis-webapi/v3/invoke" // 沙箱环境 - RequestPost = "POST" - RequestGet = "GET" + TokenURL = "https://exam-anubis.ele.me/anubis-webapi/openapi/token" // 沙箱环境 + ApiURL = "https://exam-anubis.ele.me/anubis-webapi/v3/invoke" // 沙箱环境 + RequestPost = "POST" + RequestGet = "GET" ) // 注册请求api @@ -76,8 +76,10 @@ type GetOneStoreParam struct { // 获取单个门店基础参数(请求) type GetOneStore struct { - MerchantID string `json:"merchant_id"` // 商户id - OutShopCode string `json:"out_shop_code"` // 外部门店编码 + MerchantID string `json:"merchant_id"` // 商户id + OutShopCode string `json:"out_shop_code"` // 外部门店编码 + ChainStoreId string `json:"chain_store_id,omitempty"` // 门店id + } // 获取单个门店(返回) diff --git a/platformapi/fnpsapi/store.go b/platformapi/fnpsapi/store.go index efa29d72..27ba8e5a 100644 --- a/platformapi/fnpsapi/store.go +++ b/platformapi/fnpsapi/store.go @@ -72,7 +72,8 @@ func (a *API) GetStore(storeID string) (getStoreResult *GetOneStoreRespData, err BusinessData: "", } // 序列化请求参数 - data, err := json.Marshal(GetOneStore{MerchantID: a.merchantId, OutShopCode: storeID}) + //data, err := json.Marshal(GetOneStore{MerchantID: a.merchantId, OutShopCode: storeID}) 正式环境 + data, err := json.Marshal(GetOneStore{MerchantID: a.merchantId, ChainStoreId: storeID}) // 沙箱 if err != nil { return nil, err } diff --git a/platformapi/fnpsapi_v3/order_test.go b/platformapi/fnpsapi_v3/order_test.go index 19ee8070..2ab7f7ca 100644 --- a/platformapi/fnpsapi_v3/order_test.go +++ b/platformapi/fnpsapi_v3/order_test.go @@ -37,37 +37,6 @@ func TestPreOrder(t *testing.T) { fmt.Println(baseDeliveryFee) } -// 正式下单 -func TestCreateOrder(t *testing.T) { - api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691", "51658") - token, _ := api.GetAccessToken() - api.accessToken = token.BusinessDataObj.AccessToken - - aa := []*GoodsItemsList{ - {"白菜", 1, 100, 100, "30011", 1, "备注:大白菜"}, - //{"白菜2", 1, 100, 100, "30012", 1, "备注:大白菜2"}, - // {"白菜3", 1, 100, 100, "1004", 1, "备注:大白菜2"}, - } - err := api.CreateOrder(&CreateOrderReqParam{ - PartnerOrderCode: "232232999uue21", - OrderType: 1, - PositionSource: 3, - ReceiverAddress: "四川成都", - ReceiverLongitude: 113.546508, - ReceiverLatitude: 22.188382, - GoodsTotalAmountCent: 100, - GoodsActualAmountCent: 100, - GoodsWeight: 0.25, - GoodsCount: 1, - GoodsItemList: aa, - ReceiverName: "刘磊", - ReceiverPrimaryPhone: "18981810340", - OutShopCode: "", - ChainStoreId: "200008235", - }) - fmt.Println(err) -} - // 添加小费 func TestAddTip(t *testing.T) { api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691", "51658")