修改测试文件

This commit is contained in:
邹宗楠
2022-03-25 10:30:00 +08:00
parent c112e5e282
commit 5bc0b261ce
4 changed files with 19 additions and 13 deletions

View File

@@ -51,7 +51,7 @@ func New(appID, appSecret, merchantId, code string, config ...*platformapi.APICo
appID: appID,
merchantId: merchantId,
signature: "",
timestamp: time.Now().UnixNano(),
timestamp: time.Now().Unix() * 1000,
accessToken: "",
version: "1.0",
appSecret: appSecret,
@@ -78,8 +78,9 @@ func (a *API) signParam(params map[string]interface{}) (sig string) {
}
func (a *API) AccessAPI(baseUrl, actionApi, method string, bizParams map[string]interface{}) (retVal map[string]interface{}, err error) {
a.signature = a.signParam(bizParams)
bizParams["signature"] = a.signature
if a.signature == "" {
a.signature = a.signParam(bizParams)
}
// 序列化
data, err := json.Marshal(bizParams)
if err != nil {

View File

@@ -23,7 +23,7 @@ func TestClient(t *testing.T) {
// 创建门店,
func TestCreateStore(t *testing.T) {
api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691", "cabrXQf9eFMVWVYg4hNlwu")
api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "51658", "DDSdQhSc02m6l4oPVDELgx")
token, _ := api.GetAccessToken()
api.accessToken = token.BusinessDataObj.AccessToken
err := api.CreateStore(&CreateStoreBaseInfo{
@@ -93,8 +93,9 @@ func TestUpdataStore(t *testing.T) {
// 查询单个门店
func TestQueryOneStore(t *testing.T) {
api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691", "cabrXQf9eFMVWVYg4hNlwu")
token, _ := api.GetAccessToken()
api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "51658", "DDSdQhSc02m6l4oPVDELgx")
token, err := api.GetAccessToken()
fmt.Println("err1==========", err)
api.accessToken = token.BusinessDataObj.AccessToken
data, err := api.GetStore("637910")
fmt.Println(data)

View File

@@ -43,7 +43,7 @@ func New(appID, appSecret, merchantId, code string, config ...*platformapi.APICo
appID: appID,
merchantId: merchantId,
signature: "",
timestamp: time.Now().UnixNano(),
timestamp: time.Now().Unix() * 1000,
accessToken: "",
version: "1.0",
appSecret: appSecret,
@@ -77,6 +77,7 @@ func (a *API) GetAccessToken() (tokenInfo *TokenInfo, err error) {
parameter["app_id"] = a.appID
parameter["merchant_id"] = a.merchantId
parameter["timestamp"] = utils.Int64ToStr(a.timestamp)
parameter["signature"] = a.signParam
result, err := a.AccessAPI(TokenURL, "", RequestPost, parameter)
if err != nil {
@@ -95,7 +96,9 @@ func (a *API) GetAccessToken() (tokenInfo *TokenInfo, err error) {
}
func (a *API) AccessAPI(baseUrl, actionApi, method string, bizParams map[string]interface{}) (retVal map[string]interface{}, err error) {
a.signature = a.signParam(bizParams)
if a.signature == "" {
a.signature = a.signParam(bizParams)
}
bizParams["signature"] = a.signature
// 序列化
data, err := json.Marshal(bizParams)

View File

@@ -8,7 +8,7 @@ import (
// 预下单
func TestPreOrder(t *testing.T) {
api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691")
api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691", "51658")
token, _ := api.GetAccessToken()
api.accessToken = token.BusinessDataObj.AccessToken
@@ -39,7 +39,7 @@ func TestPreOrder(t *testing.T) {
// 正式下单
func TestCreateOrder(t *testing.T) {
api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691")
api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691", "51658")
token, _ := api.GetAccessToken()
api.accessToken = token.BusinessDataObj.AccessToken
@@ -70,7 +70,7 @@ func TestCreateOrder(t *testing.T) {
// 添加小费
func TestAddTip(t *testing.T) {
api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691")
api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691", "51658")
token, _ := api.GetAccessToken()
api.accessToken = token.BusinessDataObj.AccessToken
@@ -85,8 +85,9 @@ func TestAddTip(t *testing.T) {
// 获取可用取消订单原因
func TestGetCancelReasonList(t *testing.T) {
api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691")
token, _ := api.GetAccessToken()
api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691", "DDSdQhSc02m6l4oPVDELgx")
token, err := api.GetAccessToken()
fmt.Println(err)
api.accessToken = token.BusinessDataObj.AccessToken
data, err := api.GetCancelReasonList(&GetOrderDetailReq{