Skip to content

Commit 4fd58a8

Browse files
committed
Merge pull request #186 from ssls/master
公众号支持消息转发到多客服
2 parents cf9ccbc + 2942e1e commit 4fd58a8

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ weixin-java-tools
5050
* [1.0.3升级指南](https://github.com/chanjarster/weixin-java-tools/wiki/1_0_3升级指南)
5151
* [1.1.0升级指南](https://github.com/chanjarster/weixin-java-tools/wiki/1_1_0升级指南)
5252
* [1.1.1升级指南](https://github.com/chanjarster/weixin-java-tools/wiki/1_1_1升级指南)
53+
54+
## 关于Pull Request
55+
56+
非常欢迎和感谢对本项目发起Pull Request的同学,不过本项目基于[git flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)开发流程,因此在发起Pull Request的时候请选择develop分支。

weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class WxConsts {
2929
public static final String CUSTOM_MSG_MUSIC = "music";
3030
public static final String CUSTOM_MSG_NEWS = "news";
3131
public static final String CUSTOM_MSG_FILE = "file";
32+
public static final String CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service";
3233

3334
///////////////////////
3435
// 群发消息的消息类型

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlOutMessage.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,12 @@ public static MusicBuilder MUSIC() {
121121
public static NewsBuilder NEWS() {
122122
return new NewsBuilder();
123123
}
124+
/**
125+
* 获得客服消息builder
126+
*
127+
* @return
128+
*/
129+
public static TransferCustomerServiceBuilder TRANSFER_CUSTOMER_SERVICE() {
130+
return new TransferCustomerServiceBuilder();
131+
}
124132
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package me.chanjar.weixin.mp.bean;
2+
3+
import com.thoughtworks.xstream.annotations.XStreamAlias;
4+
import com.thoughtworks.xstream.annotations.XStreamConverter;
5+
import me.chanjar.weixin.common.api.WxConsts;
6+
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
7+
import me.chanjar.weixin.common.util.xml.XStreamMediaIdConverter;
8+
9+
@XStreamAlias("xml")
10+
public class WxMpXmlOutTransferCustomerServiceMessage extends WxMpXmlOutMessage {
11+
@XStreamAlias("TransInfo")
12+
protected final TransInfo transInfo = new TransInfo();
13+
14+
public WxMpXmlOutTransferCustomerServiceMessage() {
15+
this.msgType = WxConsts.CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE;
16+
}
17+
18+
public String getKfAccount() {
19+
return transInfo.getKfAccount();
20+
}
21+
22+
public void setKfAccount(String kfAccount) {
23+
transInfo.setKfAccount(kfAccount);
24+
}
25+
26+
@XStreamAlias("TransInfo")
27+
public static class TransInfo {
28+
29+
@XStreamAlias("KfAccount")
30+
@XStreamConverter(value=XStreamCDataConverter.class)
31+
private String kfAccount;
32+
33+
public String getKfAccount() {
34+
return kfAccount;
35+
}
36+
37+
public void setKfAccount(String kfAccount) {
38+
this.kfAccount = kfAccount;
39+
}
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package me.chanjar.weixin.mp.bean.outxmlbuilder;
2+
3+
import me.chanjar.weixin.mp.bean.WxMpXmlOutTransferCustomerServiceMessage;
4+
5+
/**
6+
* 客服消息builder
7+
* <pre>
8+
* 用法: WxMpCustomMessage m = WxMpCustomMessage.TRANSFER_CUSTOMER_SERVICE().content(...).toUser(...).build();
9+
* </pre>
10+
*
11+
* @author chanjarster
12+
*/
13+
public final class TransferCustomerServiceBuilder extends BaseBuilder<TransferCustomerServiceBuilder, WxMpXmlOutTransferCustomerServiceMessage> {
14+
private String kfAccount;
15+
16+
public TransferCustomerServiceBuilder kfAccount(String kfAccount) {
17+
this.kfAccount = kfAccount;
18+
return this;
19+
}
20+
21+
22+
public WxMpXmlOutTransferCustomerServiceMessage build() {
23+
WxMpXmlOutTransferCustomerServiceMessage m = new WxMpXmlOutTransferCustomerServiceMessage();
24+
setCommon(m);
25+
m.setKfAccount(kfAccount);
26+
return m;
27+
}
28+
}

0 commit comments

Comments
 (0)