新增查询京东商城用户关联门店接口
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
@@ -227,6 +228,8 @@ var (
|
||||
"403": 1,
|
||||
}
|
||||
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 (
|
||||
@@ -537,3 +540,25 @@ func (a *API) SaveQualify(stationNo string, actionType int, qualifyList []*Quali
|
||||
}, true, "")
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package jdapi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
@@ -189,3 +190,11 @@ func TestSaveQualify(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetJdUserBindStoreIDs(t *testing.T) {
|
||||
vv, err := api.GetJdUserBindStoreIDs(339890)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fmt.Println(vv)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user