This commit is contained in:
邹宗楠
2022-10-09 13:52:34 +08:00
parent 665653c4ed
commit 1fc2ff91f1
3 changed files with 9 additions and 2 deletions

View File

@@ -44,7 +44,7 @@ func New(appKey, appSecret, accessToken string) *API {
expiresIn: access.ExpiresIn,
accessTokenObj: access,
}
if access.ExpiresIn > time.Now().Unix() {
if access.ExpiresIn < time.Now().Unix() {
api.RefreshToken()
}
return api

View File

@@ -214,7 +214,7 @@ func (a *API) GetStoreBindTemp(storeId int64) (freightId int64, err error) {
if err != nil {
return 0, err
}
if len(result.Data.StoreFreights) == 0 {
if result.Data == nil || len(result.Data.StoreFreights) == 0 {
return 0, nil
}
for _, v := range result.Data.StoreFreights {

View File

@@ -35,3 +35,10 @@ func TestCreateStore(t *testing.T) {
func TestSysnc(t *testing.T) {
fmt.Println((2 & 2) != 0) // 创建
}
func TestStoreTemp(t *testing.T) {
token := `{"access_token":"a1746210-a8a3-4497-a87b-09d1f10dbb95","expires_in":1665652230,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"c1cf8d88-0983-4f2a-b969-3746fae6b0cd","authority_id":""}`
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token)
a.GetStoreBindTemp(63114504)
}