Merge branch 'master' of e.coding.net:rosydev/baseapi

This commit is contained in:
gazebo
2019-11-28 14:13:46 +08:00
2 changed files with 25 additions and 0 deletions

View File

@@ -227,6 +227,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 +539,17 @@ func (a *API) SaveQualify(stationNo string, actionType int, qualifyList []*Quali
}, true, "")
return err
}
func (a *API) GetJdUserBindStoreIDs(userID int) (vendorStoreIDs []string, err error) {
body, err := a.AccessStorePage2("https://login-o2o.jddj.com/jpuser/bindStore/"+utils.Int2Str(userID), nil, 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
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)
}