Skip to content

Commit 72c46d1

Browse files
committed
按照最新微信官方文档对客服会话控制接口进行修正
1 parent 42ce9a1 commit 72c46d1

File tree

4 files changed

+10
-29
lines changed

4 files changed

+10
-29
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ boolean kfAccountUploadHeadImg(String kfAccount, File imgFile)
9494
* 接口url格式: https://api.weixin.qq.com/customservice/kfsession/create?access_token=ACCESS_TOKEN
9595
* </pre>
9696
*/
97-
boolean kfSessionCreate(String openid, String kfAccount, String text) throws WxErrorException;
97+
boolean kfSessionCreate(String openid, String kfAccount) throws WxErrorException;
9898

9999
/**
100100
* <pre>
@@ -104,7 +104,7 @@ boolean kfAccountUploadHeadImg(String kfAccount, File imgFile)
104104
* 接口url格式: https://api.weixin.qq.com/customservice/kfsession/close?access_token=ACCESS_TOKEN
105105
* </pre>
106106
*/
107-
boolean kfSessionClose(String openid, String kfAccount, String text) throws WxErrorException;
107+
boolean kfSessionClose(String openid, String kfAccount) throws WxErrorException;
108108

109109
/**
110110
* <pre>

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,19 @@ public boolean kfAccountDel(String kfAccount) throws WxErrorException {
8888
}
8989

9090
@Override
91-
public boolean kfSessionCreate(String openid, String kfAccount, String text)
91+
public boolean kfSessionCreate(String openid, String kfAccount)
9292
throws WxErrorException {
93-
WxMpKfSessionRequest request = new WxMpKfSessionRequest(kfAccount, openid,
94-
text);
93+
WxMpKfSessionRequest request = new WxMpKfSessionRequest(kfAccount, openid);
9594
String url = "https://api.weixin.qq.com/customservice/kfsession/create";
9695
this.wxMpService.execute(new SimplePostRequestExecutor(), url,
9796
request.toJson());
9897
return true;
9998
}
10099

101100
@Override
102-
public boolean kfSessionClose(String openid, String kfAccount, String text)
101+
public boolean kfSessionClose(String openid, String kfAccount)
103102
throws WxErrorException {
104-
WxMpKfSessionRequest request = new WxMpKfSessionRequest(kfAccount, openid,
105-
text);
103+
WxMpKfSessionRequest request = new WxMpKfSessionRequest(kfAccount, openid);
106104
String url = "https://api.weixin.qq.com/customservice/kfsession/close";
107105
this.wxMpService.execute(new SimplePostRequestExecutor(), url,
108106
request.toJson());

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

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,10 @@ public class WxMpKfSessionRequest implements Serializable {
2323
*/
2424
@SerializedName("openid")
2525
private String openid;
26-
27-
/**
28-
* text 附加信息,文本会展示在客服人员的多客服客户端
29-
* 目前看起来无用,主要是老版的多客服客户端使用
30-
*/
31-
@SerializedName("text")
32-
@Deprecated
33-
private String text;
34-
35-
public WxMpKfSessionRequest(String kfAccount, String openid, String text) {
26+
27+
public WxMpKfSessionRequest(String kfAccount, String openid) {
3628
this.kfAccount = kfAccount;
3729
this.openid = openid;
38-
this.text = text;
3930
}
4031

4132
@Override
@@ -55,12 +46,4 @@ public void setKfAccount(String kfAccount) {
5546
this.kfAccount = kfAccount;
5647
}
5748

58-
public String getText() {
59-
return this.text;
60-
}
61-
62-
public void setText(String text) {
63-
this.text = text;
64-
}
65-
6649
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ public Object[][] getKfAccountAndOpenid() {
108108
public void testKfSessionCreate(String kfAccount, String openid)
109109
throws WxErrorException {
110110
boolean result = this.wxService.getKefuService().kfSessionCreate(openid,
111-
kfAccount, "welcome");
111+
kfAccount);
112112
Assert.assertTrue(result);
113113
}
114114

115115
@Test(dataProvider = "getKfAccountAndOpenid")
116116
public void testKfSessionClose(String kfAccount, String openid)
117117
throws WxErrorException {
118118
boolean result = this.wxService.getKefuService().kfSessionClose(openid,
119-
kfAccount, "bye bye");
119+
kfAccount);
120120
Assert.assertTrue(result);
121121
}
122122

0 commit comments

Comments
 (0)