获取京东用户接口修改

This commit is contained in:
苏尹岚
2019-11-29 11:11:38 +08:00
parent b9bfcd1983
commit 3546675915
2 changed files with 76 additions and 51 deletions

View File

@@ -256,39 +256,6 @@ type UpdateStoreFreightParam struct {
FreeFreightInfoList []*FreeFreightInfo `json:"freeFreightInfoList,omitempty"`
}
type StoreUserInfo struct {
Cn string `json:"cn"`
CreateApp string `json:"createApp"`
CreatePin string `json:"createPin"`
CreateTime *utils.JavaDate `json:"createTime"`
DefaultPwdType interface{} `json:"defaultPwdType"`
Email interface{} `json:"email"`
ErpAccount interface{} `json:"erpAccount"`
ExtFields struct {
OrgName string `json:"orgName"`
} `json:"extFields"`
ID int `json:"id"`
JdPin interface{} `json:"jdPin"`
LastLoginTime interface{} `json:"lastLoginTime"`
LockStatus int `json:"lockStatus"`
LoginCredentials interface{} `json:"loginCredentials"`
LoginFailCount int `json:"loginFailCount"`
LoginName string `json:"loginName"`
OrgCode string `json:"orgCode"`
OrgID int `json:"orgId"`
PartTimeOrgIds interface{} `json:"partTimeOrgIds"`
Phone string `json:"phone"`
Remark interface{} `json:"remark"`
RoleNameStr interface{} `json:"roleNameStr"`
Roles interface{} `json:"roles"`
SortNo int `json:"sortNo"`
Status int `json:"status"`
SysVersion int `json:"sysVersion"`
UpdatePin interface{} `json:"updatePin"`
UpdateTime interface{} `json:"updateTime"`
UserCode string `json:"userCode"`
}
func (a *API) GetAllCities() (cities []*CityInfo, err error) {
result, err := a.AccessAPINoPage("address/allcities", nil, nil, nil, genNoPageResultParser("code", "msg", "result", "0"))
if err == nil {
@@ -489,21 +456,3 @@ func parsePrivilegeSearchUser(data map[string]interface{}) (innerData interface{
}
return innerData, err
}
// 查询商家中心账号信息接口
// https://openo2o.jddj.com/staticnew/widgets/resources.html?groupid=194&apiid=67a5cd92e9704612b77064401a696144
func (a *API) PrivilegeSearchUser(pageNo, pageSize int) (storeUserList []*StoreUserInfo, err error) {
jdParams := map[string]interface{}{
"pageNo": utils.Int2Str(pageNo),
"pageSize": utils.Int2Str(pageSize),
}
result, err := a.AccessAPINoPage("privilege/searchUser", jdParams, nil, nil, parsePrivilegeSearchUser)
if err == nil {
err = utils.Map2StructByJson(result, &storeUserList, false)
}
return storeUserList, err
}
func (a *API) PrivilegeSearchUserAll() (storeUserList []*StoreUserInfo, err error) {
return a.PrivilegeSearchUser(1, 1)
}

View File

@@ -196,6 +196,39 @@ type PageSku struct {
VenderID string `json:"venderId"`
}
type StoreUserInfo struct {
Cn string `json:"cn"`
CreateApp string `json:"createApp"`
CreatePin string `json:"createPin"`
CreateTime *utils.JavaDate `json:"createTime"`
DefaultPwdType interface{} `json:"defaultPwdType"`
Email interface{} `json:"email"`
ErpAccount interface{} `json:"erpAccount"`
ExtFields struct {
OrgName string `json:"orgName"`
} `json:"extFields"`
ID int `json:"id"`
JdPin interface{} `json:"jdPin"`
LastLoginTime interface{} `json:"lastLoginTime"`
LockStatus string `json:"lockStatus"`
LoginCredentials interface{} `json:"loginCredentials"`
LoginFailCount int `json:"loginFailCount"`
LoginName string `json:"loginName"`
OrgCode string `json:"orgCode"`
OrgID int `json:"orgId"`
PartTimeOrgIds interface{} `json:"partTimeOrgIds"`
Phone string `json:"phone"`
Remark interface{} `json:"remark"`
RoleNameStr interface{} `json:"roleNameStr"`
Roles interface{} `json:"roles"`
SortNo int `json:"sortNo"`
Status int `json:"status"`
SysVersion int `json:"sysVersion"`
UpdatePin interface{} `json:"updatePin"`
UpdateTime interface{} `json:"updateTime"`
UserCode string `json:"userCode"`
}
const (
QualifyTypeCompany = "25" // 营业执照
QualifyTypePerson = "22" // 身份证,个体工商户要求填
@@ -229,6 +262,9 @@ var (
pageCanRetryCodes = map[string]int{}
regexpTable = regexp.MustCompile(`<table class="check-container" data-container="list1">([\s\S]*?)</table>`)
regexpTd = regexp.MustCompile(`<td>([0-9].*)</td>`)
regexpJDUserPage = regexp.MustCompile(`共([\s\S].*)页/([\s\S].*)条记录`)
regexpJDUserList = regexp.MustCompile(`<input type="checkbox"></td>([\s\S]*?)<input`)
regexpJDUserInfo = regexp.MustCompile(`<td>(.*)</td>`)
)
const (
@@ -553,3 +589,43 @@ func (a *API) GetJdUserBindStoreIDs(userID int) (vendorStoreIDs []string, err er
}
return vendorStoreIDs, err
}
// 查询商家中心账号信息接口
// https://login-o2o.jddj.com/jpuser/list?doPage=false&pageNo=1&appCode=lsp-store&pageSize=20&autoCount=false&_=1574936207872
func (a *API) PrivilegeSearchUser(pageNo int) (storeUserList []*StoreUserInfo, totalCount, totalPage int, err error) {
params := map[string]interface{}{
"pageNo": pageNo,
"appCode": "lsp-store",
}
body, err := a.AccessStorePage2("https://login-o2o.jddj.com/jpuser/list", params, false, "")
if err != nil {
return nil, 0, 0, err
}
bodyStr := body.(string)
list := regexpJDUserList.FindAllStringSubmatch(bodyStr, -1)
totalCount = int(utils.Str2Int64(regexpJDUserPage.FindStringSubmatch(bodyStr)[2]))
totalPage = int(utils.Str2Int64(regexpJDUserPage.FindStringSubmatch(bodyStr)[1]))
for _, v := range list {
tdList := regexpJDUserInfo.FindAllStringSubmatch(v[1], -1)
storeUserInfo := &StoreUserInfo{
LoginName: tdList[0][1],
LockStatus: tdList[9][1],
}
storeUserList = append(storeUserList, storeUserInfo)
}
return storeUserList, totalCount, totalPage, err
}
// 查询商家中心账号信息接口
// https://login-o2o.jddj.com/jpuser/list?doPage=false&pageNo=1&appCode=lsp-store&pageSize=20&autoCount=false&_=1574936207872
func (a *API) PrivilegeSearchUserAll() (storeUserLists []*StoreUserInfo, err error) {
_, _, totalPage, err := a.PrivilegeSearchUser(1)
for i := 1; i <= totalPage; i++ {
storeUserList, _, _, err := a.PrivilegeSearchUser(i)
if err != nil {
return nil, err
}
storeUserLists = append(storeUserLists, storeUserList...)
}
return storeUserLists, err
}