新增查询京东商城用户关联门店接口

This commit is contained in:
苏尹岚
2019-11-28 08:51:14 +08:00
parent caac72c232
commit a784eaa8b2
2 changed files with 34 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ import (
"net/url" "net/url"
"regexp" "regexp"
"strings" "strings"
"time"
"git.rosy.net.cn/baseapi" "git.rosy.net.cn/baseapi"
"git.rosy.net.cn/baseapi/platformapi" "git.rosy.net.cn/baseapi/platformapi"
@@ -227,6 +228,8 @@ var (
"403": 1, "403": 1,
} }
pageCanRetryCodes = map[string]int{} pageCanRetryCodes = map[string]int{}
regexpTable = regexp.MustCompile(`<table class="check-container" data-container="list1">([\s\S]*?)</table>`)
regexpTd = regexp.MustCompile(`<td>([0-9].*)</td>`)
) )
const ( const (
@@ -537,3 +540,25 @@ func (a *API) SaveQualify(stationNo string, actionType int, qualifyList []*Quali
}, true, "") }, true, "")
return err return err
} }
func (a *API) GetJdUserBindStoreIDs(userID int) (vendorStoreIDs []string, err error) {
unix := time.Now().Unix() * 1000
params := map[string]interface{}{
"stationName": "",
"stationNo": "",
"city": "",
"_": utils.Int64ToStr(unix),
"userId": utils.Int2Str(userID),
}
body, err := a.AccessStorePage2("https://login-o2o.jddj.com/jpuser/bindStore/"+utils.Int2Str(userID), params, false, "")
if err != nil {
return nil, err
}
bodyStr := body.(string)
tableStr := regexpTable.FindString(bodyStr)
vendorStoreIDsRegexp := regexpTd.FindAllStringSubmatch(tableStr, -1)
for _, v := range vendorStoreIDsRegexp {
vendorStoreIDs = append(vendorStoreIDs, v[1])
}
return vendorStoreIDs, err
}

View File

@@ -1,6 +1,7 @@
package jdapi package jdapi
import ( import (
"fmt"
"testing" "testing"
"git.rosy.net.cn/baseapi" "git.rosy.net.cn/baseapi"
@@ -189,3 +190,11 @@ func TestSaveQualify(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
} }
func TestGetJdUserBindStoreIDs(t *testing.T) {
vv, err := api.GetJdUserBindStoreIDs(339890)
if err != nil {
t.Fatal(err)
}
fmt.Println(vv)
}