京东门店等级获取
This commit is contained in:
@@ -21,8 +21,6 @@ const (
|
|||||||
accessStorePageCookieName = "shop.o2o.jd.com1"
|
accessStorePageCookieName = "shop.o2o.jd.com1"
|
||||||
accessStorePageCookieName2 = "lsp-store1.jddj.com"
|
accessStorePageCookieName2 = "lsp-store1.jddj.com"
|
||||||
accessStorePageCookieName3 = "josl-privilege1.jddj.com"
|
accessStorePageCookieName3 = "josl-privilege1.jddj.com"
|
||||||
|
|
||||||
htmlResponeURL = "login-o2o.jddj.com/jpuser/"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type SkuPageImg struct {
|
type SkuPageImg struct {
|
||||||
@@ -276,9 +274,14 @@ var (
|
|||||||
regexpTd = regexp.MustCompile(`<td>([0-9].*)</td>`)
|
regexpTd = regexp.MustCompile(`<td>([0-9].*)</td>`)
|
||||||
regexpJDUserPage = regexp.MustCompile(`共([\s\S].*)页/([\s\S].*)条记录`)
|
regexpJDUserPage = regexp.MustCompile(`共([\s\S].*)页/([\s\S].*)条记录`)
|
||||||
regexpJDTr = regexp.MustCompile(`<tr>([\s\S]*?)</tr>`)
|
regexpJDTr = regexp.MustCompile(`<tr>([\s\S]*?)</tr>`)
|
||||||
regexpJDUserInfo = regexp.MustCompile(`<td>([\s\S]*?)</td>`)
|
regexpJDTdInfo = regexp.MustCompile(`<td>([\s\S]*?)</td>`)
|
||||||
regexpJDUserID = regexp.MustCompile(`value="(.*)"`)
|
regexpJDUserID = regexp.MustCompile(`value="(.*)"`)
|
||||||
regexpJDUserIsManager = regexp.MustCompile(`<div class="list-mask">`)
|
regexpJDUserIsManager = regexp.MustCompile(`<div class="list-mask">`)
|
||||||
|
regexpJDStoreLevel = regexp.MustCompile(`门店分级 :(.*);`)
|
||||||
|
htmlResponeURLs = []string{
|
||||||
|
"login-o2o.jddj.com/jpuser/",
|
||||||
|
"sta-store.jddj.com/store/",
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -346,9 +349,11 @@ func (a *API) AccessStorePage2(fullURL string, params map[string]interface{}, is
|
|||||||
if jsonResult1 == nil {
|
if jsonResult1 == nil {
|
||||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||||
}
|
}
|
||||||
if strings.Index(fullURL, htmlResponeURL) >= 0 && jsonResult1[platformapi.KeyData] != nil {
|
for _, v := range htmlResponeURLs {
|
||||||
retVal = bodyStr
|
if strings.Index(fullURL, v) >= 0 && jsonResult1[platformapi.KeyData] != nil {
|
||||||
return platformapi.ErrLevelSuccess, nil
|
retVal = bodyStr
|
||||||
|
return platformapi.ErrLevelSuccess, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
retVal = jsonResult1
|
retVal = jsonResult1
|
||||||
var errMsg string
|
var errMsg string
|
||||||
@@ -635,7 +640,7 @@ func (a *API) PrivilegeSearchUser(pageNo int) (storeUserList []*StoreUserInfo, t
|
|||||||
totalCount = int(utils.Str2Int64(regexpJDUserPage.FindStringSubmatch(bodyStr)[2]))
|
totalCount = int(utils.Str2Int64(regexpJDUserPage.FindStringSubmatch(bodyStr)[2]))
|
||||||
totalPage = int(utils.Str2Int64(regexpJDUserPage.FindStringSubmatch(bodyStr)[1]))
|
totalPage = int(utils.Str2Int64(regexpJDUserPage.FindStringSubmatch(bodyStr)[1]))
|
||||||
for _, v := range list {
|
for _, v := range list {
|
||||||
tdList := regexpJDUserInfo.FindAllStringSubmatch(v[1], -1)
|
tdList := regexpJDTdInfo.FindAllStringSubmatch(v[1], -1)
|
||||||
if len(tdList) > 0 {
|
if len(tdList) > 0 {
|
||||||
id := regexpJDUserID.FindStringSubmatch(tdList[10][0])[1]
|
id := regexpJDUserID.FindStringSubmatch(tdList[10][0])[1]
|
||||||
storeUserInfo := &StoreUserInfo{
|
storeUserInfo := &StoreUserInfo{
|
||||||
@@ -720,3 +725,33 @@ func (a *API) IsJdManagerUser(id int64) (isManager bool, err error) {
|
|||||||
return true, err
|
return true, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询京东门店等级
|
||||||
|
// 无法得到总数,循环50页后放弃寻找。。
|
||||||
|
// https://sta-store.jddj.com/store/logquery?venderId=320406&stationNo=11733018¤tPage=1&pageSize=20
|
||||||
|
func (a *API) GetJdStoreLevel(vendorOrgCode, vendorStoreID string) (level string, err error) {
|
||||||
|
for i := 1; i < 51; i++ {
|
||||||
|
jdParams := map[string]interface{}{
|
||||||
|
"venderId": vendorOrgCode,
|
||||||
|
"stationNo": vendorStoreID,
|
||||||
|
"currentPage": i,
|
||||||
|
"pageSize": 20,
|
||||||
|
}
|
||||||
|
body, err := a.AccessStorePage2("https://sta-store.jddj.com/store/logquery", jdParams, false, "")
|
||||||
|
if err != nil {
|
||||||
|
return "0", err
|
||||||
|
}
|
||||||
|
bodyStr := body.(string)
|
||||||
|
levelList := regexpJDStoreLevel.FindAllStringSubmatch(bodyStr, 1)
|
||||||
|
if len(levelList) > 0 {
|
||||||
|
level = levelList[0][1]
|
||||||
|
}
|
||||||
|
if level != "" {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if i == 50 {
|
||||||
|
level = "0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return level, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -226,3 +226,7 @@ func TestIsJdManagerUser(t *testing.T) {
|
|||||||
aa, _ := api.IsJdManagerUser(334683)
|
aa, _ := api.IsJdManagerUser(334683)
|
||||||
fmt.Println(aa)
|
fmt.Println(aa)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetJdStoreLevel(t *testing.T) {
|
||||||
|
api.GetJdStoreLevel("320406", "11732427")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user