京东商家后台接口返回修改

This commit is contained in:
苏尹岚
2019-12-03 08:53:54 +08:00
parent 1dc40112d5
commit 8fe245e8bb
2 changed files with 35 additions and 8 deletions

View File

@@ -256,6 +256,16 @@ type QualifyItem struct {
Scope string `json:"scope,omitempty"`
}
type JdUserPostResult struct {
Record interface{} `json:"record"`
RecordID string `json:"recordId"`
Status struct {
ErrorCode interface{} `json:"errorCode"`
Message interface{} `json:"message"`
Result string `json:"result"`
} `json:"status"`
}
var (
monthSaleNumReg = regexp.MustCompile(`(\d+)([千|万])`)
pageExceedLimitCodes = map[string]int{
@@ -657,7 +667,7 @@ func (a *API) PrivilegeSearchUserAll() (storeUserLists []*StoreUserInfo, err err
// 禁用/启用商家中心账号信息接口
// https: //login-o2o.jddj.com/jpuser/enable/346408
// https: //login-o2o.jddj.com/jpuser/disable/346408
func (a *API) PrivilegeUpdateJdUserStatus(id int64, status int) (err error) {
func (a *API) PrivilegeUpdateJdUserStatus(id int64, status int) (jdUserPostResult JdUserPostResult, err error) {
url := "https://login-o2o.jddj.com/jpuser/"
if status == JdUserStatusEnable {
url += "enable/"
@@ -665,21 +675,30 @@ func (a *API) PrivilegeUpdateJdUserStatus(id int64, status int) (err error) {
url += "disable/"
}
url += utils.Int64ToStr(id)
_, err = a.AccessStorePage(url, nil, true)
return err
result, err := a.AccessStorePage2(url, nil, true, "responses")
if err == nil {
resultList := result.([]interface{})
resultMap := resultList[0].(map[string]interface{})
utils.Map2StructByJson(resultMap, &jdUserPostResult, true)
}
return jdUserPostResult, err
}
// 更改商家中心账号角色接口
// https://login-o2o.jddj.com/jpuser/binduserrole/346568/update?appCode=lsp-store
//roleIds: 28926拣货员
func (a *API) UpdateJdUserRoles(id int64, roleIDs []string) (err error) {
func (a *API) UpdateJdUserRoles(id int64, roleIDs []string) (jdUserPostResult JdUserPostResult, err error) {
url := "https://login-o2o.jddj.com/jpuser/binduserrole/" + utils.Int64ToStr(id) + "/update"
jdParams := map[string]interface{}{
"appCode": "lsp-store",
"roleIds": strings.Join(roleIDs, ","),
}
_, err = a.AccessStorePage(url, jdParams, true)
return err
result, err := a.AccessStorePage2(url, jdParams, true, "")
if err == nil {
resultMap := result.(map[string]interface{})
utils.Map2StructByJson(resultMap, &jdUserPostResult, true)
}
return jdUserPostResult, err
}
// 查询用户是否是商家管理员接口

View File

@@ -207,11 +207,19 @@ func TestPrivilegeSearchUser(t *testing.T) {
}
func TestPrivilegeUpdateJdUserStatus(t *testing.T) {
api.PrivilegeUpdateJdUserStatus(346415, 0)
result, err := api.PrivilegeUpdateJdUserStatus(339020, 1)
if err != nil {
t.Fatal(err)
}
fmt.Println(result)
}
func TestUpdateJdUserRoles(t *testing.T) {
api.UpdateJdUserRoles(346568, []string{"28926", "28924"})
result, err := api.UpdateJdUserRoles(345919, []string{"28926"})
if err != nil {
t.Fatal(err)
}
fmt.Println(result)
}
func TestIsJdManagerUser(t *testing.T) {