回调打桩

This commit is contained in:
邹宗楠
2022-03-30 17:34:36 +08:00
parent 78a23f293b
commit 798c5fcaf8
4 changed files with 54 additions and 53 deletions

View File

@@ -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", "")

View File

@@ -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
}
// 获取单个门店(返回)

View File

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

View File

@@ -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")