Skip to content

Commit 3534234

Browse files
committed
按照最新文档对客服管理接口进行修正
1 parent 754e09e commit 3534234

File tree

5 files changed

+106
-64
lines changed

5 files changed

+106
-64
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public interface WxMpKefuService {
2424
/**
2525
* <pre>
2626
* 获取客服基本信息
27-
* 详情请见:<a href="http://mp.weixin.qq.com/wiki/18/749901f4e123170fb8a4d447ae6040ba.html">客服管理</a>
27+
* 详情请见:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1458044813&token=&lang=zh_CN">客服管理</a>
2828
* 接口url格式:https://api.weixin.qq.com/cgi-bin/customservice/getkflist?access_token=ACCESS_TOKEN
2929
* </pre>
3030
*/
@@ -33,7 +33,7 @@ public interface WxMpKefuService {
3333
/**
3434
* <pre>
3535
* 获取在线客服接待信息
36-
* 详情请见:<a href="http://mp.weixin.qq.com/wiki/18/749901f4e123170fb8a4d447ae6040ba.html">客服管理</a>
36+
* 详情请见:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1458044813&token=&lang=zh_CN">客服管理</a>
3737
* 接口url格式:https://api.weixin.qq.com/cgi-bin/customservice/getonlinekflist?access_token=ACCESS_TOKEN
3838
* </pre>
3939
*/
@@ -42,25 +42,34 @@ public interface WxMpKefuService {
4242
/**
4343
* <pre>
4444
* 添加客服账号
45-
* 详情请见:<a href="http://mp.weixin.qq.com/wiki/18/749901f4e123170fb8a4d447ae6040ba.html">客服管理</a>
45+
* 详情请见:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1458044813&token=&lang=zh_CN">客服管理</a>
4646
* 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/add?access_token=ACCESS_TOKEN
4747
* </pre>
4848
*/
4949
boolean kfAccountAdd(WxMpKfAccountRequest request) throws WxErrorException;
5050

5151
/**
5252
* <pre>
53-
* 设置客服信息(更新
54-
* 详情请见:<a href="http://mp.weixin.qq.com/wiki/18/749901f4e123170fb8a4d447ae6040ba.html">客服管理</a>
53+
* 设置客服信息(即更新客服信息
54+
* 详情请见:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1458044813&token=&lang=zh_CN">客服管理</a>
5555
* 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/update?access_token=ACCESS_TOKEN
5656
* </pre>
5757
*/
5858
boolean kfAccountUpdate(WxMpKfAccountRequest request) throws WxErrorException;
5959

60+
/**
61+
* <pre>
62+
* 设置客服信息(即更新客服信息)
63+
* 详情请见:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1458044813&token=&lang=zh_CN">客服管理</a>
64+
* 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/inviteworker?access_token=ACCESS_TOKEN
65+
* </pre>
66+
*/
67+
boolean kfAccountInviteWorker(WxMpKfAccountRequest request) throws WxErrorException;
68+
6069
/**
6170
* <pre>
6271
* 上传客服头像
63-
* 详情请见:<a href="http://mp.weixin.qq.com/wiki/18/749901f4e123170fb8a4d447ae6040ba.html">客服管理</a>
72+
* 详情请见:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1458044813&token=&lang=zh_CN">客服管理</a>
6473
* 接口url格式:http://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT
6574
* </pre>
6675
*/
@@ -70,7 +79,7 @@ boolean kfAccountUploadHeadImg(String kfAccount, File imgFile)
7079
/**
7180
* <pre>
7281
* 删除客服账号
73-
* 详情请见:<a href="http://mp.weixin.qq.com/wiki/18/749901f4e123170fb8a4d447ae6040ba.html">客服管理</a>
82+
* 详情请见:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1458044813&token=&lang=zh_CN">客服管理</a>
7483
* 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/del?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT
7584
* </pre>
7685
*/

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ public boolean kfAccountUpdate(WxMpKfAccountRequest request)
6262
return true;
6363
}
6464

65+
@Override
66+
public boolean kfAccountInviteWorker(WxMpKfAccountRequest request) throws WxErrorException {
67+
String url = "https://api.weixin.qq.com/customservice/kfaccount/inviteworker";
68+
this.wxMpService.execute(new SimplePostRequestExecutor(), url,
69+
request.toJson());
70+
return true;
71+
}
72+
6573
@Override
6674
public boolean kfAccountUploadHeadImg(String kfAccount, File imgFile)
6775
throws WxErrorException {

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/request/WxMpKfAccountRequest.java

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,12 @@ public class WxMpKfAccountRequest implements Serializable {
2323
*/
2424
@SerializedName("nickname")
2525
private String nickName;
26-
27-
/**
28-
* password 客服账号登录密码,格式为密码明文的32位加密MD5值
29-
*/
30-
@SerializedName("password")
31-
private String password;
32-
26+
3327
/**
34-
* rawPassword 客服账号登录密码,明文密码,仅用于辅助操作
28+
* invite_wx 接收绑定邀请的客服微信号
3529
*/
36-
@SerializedName("rawPassword")
37-
private String rawPassword;
30+
@SerializedName("invite_wx")
31+
private String inviteWx;
3832

3933
@Override
4034
public String toString() {
@@ -61,31 +55,22 @@ public void setNickName(String nickName) {
6155
this.nickName = nickName;
6256
}
6357

64-
public String getPassword() {
65-
return this.password;
66-
}
67-
68-
public void setPassword(String password) {
69-
this.password = password;
70-
}
71-
72-
public String getRawPassword() {
73-
return this.rawPassword;
58+
public static Builder builder() {
59+
return new Builder();
7460
}
7561

76-
public void setRawPassword(String rawPassword) {
77-
this.rawPassword = rawPassword;
62+
public String getInviteWx() {
63+
return this.inviteWx;
7864
}
7965

80-
public static Builder builder() {
81-
return new Builder();
66+
public void setInviteWx(String inviteWx) {
67+
this.inviteWx = inviteWx;
8268
}
8369

8470
public static class Builder {
8571
private String kfAccount;
8672
private String nickName;
87-
private String password;
88-
private String rawPassword;
73+
private String inviteWx;
8974

9075
@SuppressWarnings("hiding")
9176
public Builder kfAccount(String kfAccount) {
@@ -100,32 +85,23 @@ public Builder nickName(String nickName) {
10085
}
10186

10287
@SuppressWarnings("hiding")
103-
public Builder password(String password) {
104-
this.password = password;
105-
return this;
106-
}
107-
108-
@SuppressWarnings("hiding")
109-
public Builder rawPassword(String rawPassword) {
110-
this.rawPassword = rawPassword;
111-
this.password(Md5Crypt.md5Crypt(rawPassword.getBytes()));
112-
return this;
88+
public Builder inviteWx(String inviteWx) {
89+
this.inviteWx = inviteWx;
90+
return this;
11391
}
11492

11593
public Builder from(WxMpKfAccountRequest origin) {
11694
this.kfAccount(origin.kfAccount);
11795
this.nickName(origin.nickName);
118-
this.password(origin.password);
119-
this.rawPassword(origin.rawPassword);
96+
this.inviteWx(origin.inviteWx);
12097
return this;
12198
}
12299

123100
public WxMpKfAccountRequest build() {
124101
WxMpKfAccountRequest m = new WxMpKfAccountRequest();
125102
m.kfAccount = this.kfAccount;
126103
m.nickName = this.nickName;
127-
m.password = this.password;
128-
m.rawPassword = this.rawPassword;
104+
m.inviteWx = this.inviteWx;
129105
return m;
130106
}
131107
}

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfInfo.java

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,34 @@ public class WxMpKfInfo implements Serializable {
4141
private String nick;
4242

4343
/**
44-
* status 客服在线状态 1:pc在线,2:手机在线。若pc和手机同时在线则为 1+2=3
44+
* kf_wx 如果客服帐号已绑定了客服人员微信号,则此处显示微信号
4545
*/
46-
@SerializedName("status")
47-
private Integer status;
46+
@SerializedName("kf_wx")
47+
private String wxAccount;
4848

4949
/**
50-
* auto_accept 客服设置的最大自动接入数
50+
* invite_wx 如果客服帐号尚未绑定微信号,但是已经发起了一个绑定邀请,则此处显示绑定邀请的微信号
5151
*/
52-
@Expose
53-
@SerializedName("auto_accept")
54-
private Integer autoAccept;
52+
@SerializedName("invite_wx")
53+
private String inviteWx;
54+
55+
/**
56+
* invite_expire_time 如果客服帐号尚未绑定微信号,但是已经发起过一个绑定邀请,则此处显示为邀请的过期时间,为unix 时间戳
57+
*/
58+
@SerializedName("invite_expire_time")
59+
private Long inviteExpireTime;
60+
61+
/**
62+
* invite_status 邀请的状态,有等待确认“waiting”,被拒绝“rejected”,过期“expired”
63+
*/
64+
@SerializedName("invite_status")
65+
private String inviteStatus;
66+
67+
/**
68+
* status 客服在线状态,目前为:1、web 在线
69+
*/
70+
@SerializedName("status")
71+
private Integer status;
5572

5673
/**
5774
* accepted_case 客服当前正在接待的会话数
@@ -68,14 +85,6 @@ public void setStatus(Integer status) {
6885
this.status = status;
6986
}
7087

71-
public Integer getAutoAccept() {
72-
return this.autoAccept;
73-
}
74-
75-
public void setAutoAccept(Integer autoAccept) {
76-
this.autoAccept = autoAccept;
77-
}
78-
7988
public Integer getAcceptedCase() {
8089
return this.acceptedCase;
8190
}
@@ -120,4 +129,36 @@ public void setNick(String nick) {
120129
public String toString() {
121130
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
122131
}
132+
133+
public String getWxAccount() {
134+
return this.wxAccount;
135+
}
136+
137+
public void setWxAccount(String wxAccount) {
138+
this.wxAccount = wxAccount;
139+
}
140+
141+
public String getInviteWx() {
142+
return this.inviteWx;
143+
}
144+
145+
public void setInviteWx(String inviteWx) {
146+
this.inviteWx = inviteWx;
147+
}
148+
149+
public Long getInviteExpireTime() {
150+
return this.inviteExpireTime;
151+
}
152+
153+
public void setInviteExpireTime(Long inviteExpireTime) {
154+
this.inviteExpireTime = inviteExpireTime;
155+
}
156+
157+
public String getInviteStatus() {
158+
return this.inviteStatus;
159+
}
160+
161+
public void setInviteStatus(String inviteStatus) {
162+
this.inviteStatus = inviteStatus;
163+
}
123164
}

weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImplTest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,26 @@ public Object[][] getKfAccount() {
6060
@Test(dataProvider = "getKfAccount")
6161
public void testKfAccountAdd(String kfAccount) throws WxErrorException {
6262
WxMpKfAccountRequest request = WxMpKfAccountRequest.builder()
63-
.kfAccount(kfAccount).nickName("我晕").rawPassword("123").build();
63+
.kfAccount(kfAccount).nickName("我晕").build();
6464
Assert.assertTrue(this.wxService.getKefuService().kfAccountAdd(request));
6565
}
6666

6767
@Test(dependsOnMethods = {
6868
"testKfAccountAdd" }, dataProvider = "getKfAccount")
6969
public void testKfAccountUpdate(String kfAccount) throws WxErrorException {
7070
WxMpKfAccountRequest request = WxMpKfAccountRequest.builder()
71-
.kfAccount(kfAccount).nickName("我晕").rawPassword("123").build();
71+
.kfAccount(kfAccount).nickName("我晕").build();
7272
Assert.assertTrue(this.wxService.getKefuService().kfAccountUpdate(request));
7373
}
7474

75+
@Test(dependsOnMethods = {
76+
"testKfAccountAdd" }, dataProvider = "getKfAccount")
77+
public void testKfAccountInviteWorker(String kfAccount) throws WxErrorException {
78+
WxMpKfAccountRequest request = WxMpKfAccountRequest.builder()
79+
.kfAccount(kfAccount).inviteWx("www_ucredit_com").build();
80+
Assert.assertTrue(this.wxService.getKefuService().kfAccountInviteWorker(request));
81+
}
82+
7583
@Test(dependsOnMethods = {
7684
"testKfAccountUpdate" }, dataProvider = "getKfAccount")
7785
public void testKfAccountUploadHeadImg(String kfAccount)

0 commit comments

Comments
 (0)