mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-23 22:11:40 +08:00
修改me.chanjar.weixin.mp.bean.WxMpXmlOutTransferCustomerServiceMessage 支持将消息转发到多客服(https://mp.weixin.qq.com/wiki/5/ae230189c9bd07a6b221f48619aeef35.html)中的两种方式
This commit is contained in:
parent
c901067509
commit
0619c3f01e
@ -4,23 +4,22 @@ import com.thoughtworks.xstream.annotations.XStreamAlias;
|
|||||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||||
import me.chanjar.weixin.common.api.WxConsts;
|
import me.chanjar.weixin.common.api.WxConsts;
|
||||||
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
|
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
|
||||||
import me.chanjar.weixin.common.util.xml.XStreamMediaIdConverter;
|
|
||||||
|
|
||||||
@XStreamAlias("xml")
|
@XStreamAlias("xml")
|
||||||
public class WxMpXmlOutTransferCustomerServiceMessage extends WxMpXmlOutMessage {
|
public class WxMpXmlOutTransferCustomerServiceMessage extends WxMpXmlOutMessage {
|
||||||
@XStreamAlias("TransInfo")
|
@XStreamAlias("TransInfo")
|
||||||
protected final TransInfo transInfo = new TransInfo();
|
protected TransInfo transInfo;
|
||||||
|
|
||||||
public WxMpXmlOutTransferCustomerServiceMessage() {
|
public WxMpXmlOutTransferCustomerServiceMessage() {
|
||||||
this.msgType = WxConsts.CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE;
|
this.msgType = WxConsts.CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKfAccount() {
|
public TransInfo getTransInfo() {
|
||||||
return transInfo.getKfAccount();
|
return transInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKfAccount(String kfAccount) {
|
public void setTransInfo(TransInfo transInfo) {
|
||||||
transInfo.setKfAccount(kfAccount);
|
this.transInfo = transInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XStreamAlias("TransInfo")
|
@XStreamAlias("TransInfo")
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.chanjar.weixin.mp.bean.outxmlbuilder;
|
package me.chanjar.weixin.mp.bean.outxmlbuilder;
|
||||||
|
|
||||||
|
import me.chanjar.weixin.common.util.StringUtils;
|
||||||
import me.chanjar.weixin.mp.bean.WxMpXmlOutTransferCustomerServiceMessage;
|
import me.chanjar.weixin.mp.bean.WxMpXmlOutTransferCustomerServiceMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,7 +23,11 @@ public final class TransferCustomerServiceBuilder extends BaseBuilder<TransferCu
|
|||||||
public WxMpXmlOutTransferCustomerServiceMessage build() {
|
public WxMpXmlOutTransferCustomerServiceMessage build() {
|
||||||
WxMpXmlOutTransferCustomerServiceMessage m = new WxMpXmlOutTransferCustomerServiceMessage();
|
WxMpXmlOutTransferCustomerServiceMessage m = new WxMpXmlOutTransferCustomerServiceMessage();
|
||||||
setCommon(m);
|
setCommon(m);
|
||||||
m.setKfAccount(kfAccount);
|
if(StringUtils.isNotBlank(kfAccount)){
|
||||||
|
WxMpXmlOutTransferCustomerServiceMessage.TransInfo transInfo = new WxMpXmlOutTransferCustomerServiceMessage.TransInfo();
|
||||||
|
transInfo.setKfAccount(kfAccount);
|
||||||
|
m.setTransInfo(transInfo);
|
||||||
|
}
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
package me.chanjar.weixin.mp.bean;
|
||||||
|
|
||||||
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ben on 2015/12/29.
|
||||||
|
*/
|
||||||
|
public class WxMpXmlOutTransferCustomerServiceMessageTest {
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
WxMpXmlOutTransferCustomerServiceMessage m = new WxMpXmlOutTransferCustomerServiceMessage();
|
||||||
|
m.setCreateTime(1399197672L);
|
||||||
|
m.setFromUserName("fromuser");
|
||||||
|
m.setToUserName("touser");
|
||||||
|
|
||||||
|
String expected = "<xml>" +
|
||||||
|
"<ToUserName><![CDATA[touser]]></ToUserName>" +
|
||||||
|
"<FromUserName><![CDATA[fromuser]]></FromUserName>" +
|
||||||
|
"<CreateTime>1399197672</CreateTime>" +
|
||||||
|
"<MsgType><![CDATA[transfer_customer_service]]></MsgType>" +
|
||||||
|
"</xml>";
|
||||||
|
System.out.println(m.toXml());
|
||||||
|
Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", ""));
|
||||||
|
|
||||||
|
expected = " <xml>" +
|
||||||
|
"<ToUserName><![CDATA[touser]]></ToUserName>" +
|
||||||
|
"<FromUserName><![CDATA[fromuser]]></FromUserName>" +
|
||||||
|
"<CreateTime>1399197672</CreateTime>" +
|
||||||
|
"<MsgType><![CDATA[transfer_customer_service]]></MsgType>" +
|
||||||
|
"<TransInfo>" +
|
||||||
|
"<KfAccount><![CDATA[test1@test]]></KfAccount>" +
|
||||||
|
"</TransInfo>" +
|
||||||
|
"</xml>";
|
||||||
|
WxMpXmlOutTransferCustomerServiceMessage.TransInfo transInfo = new WxMpXmlOutTransferCustomerServiceMessage.TransInfo();
|
||||||
|
transInfo.setKfAccount("test1@test");
|
||||||
|
m.setTransInfo(transInfo);
|
||||||
|
System.out.println(m.toXml());
|
||||||
|
Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBuild() {
|
||||||
|
WxMpXmlOutTransferCustomerServiceMessage m = WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE().fromUser("fromuser").toUser("touser").build();
|
||||||
|
m.setCreateTime(1399197672L);
|
||||||
|
String expected = "<xml>" +
|
||||||
|
"<ToUserName><![CDATA[touser]]></ToUserName>" +
|
||||||
|
"<FromUserName><![CDATA[fromuser]]></FromUserName>" +
|
||||||
|
"<CreateTime>1399197672</CreateTime>" +
|
||||||
|
"<MsgType><![CDATA[transfer_customer_service]]></MsgType>" +
|
||||||
|
"</xml>";
|
||||||
|
System.out.println(m.toXml());
|
||||||
|
Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", ""));
|
||||||
|
|
||||||
|
|
||||||
|
expected = " <xml>" +
|
||||||
|
"<ToUserName><![CDATA[touser]]></ToUserName>" +
|
||||||
|
"<FromUserName><![CDATA[fromuser]]></FromUserName>" +
|
||||||
|
"<CreateTime>1399197672</CreateTime>" +
|
||||||
|
"<MsgType><![CDATA[transfer_customer_service]]></MsgType>" +
|
||||||
|
"<TransInfo>" +
|
||||||
|
"<KfAccount><![CDATA[test1@test]]></KfAccount>" +
|
||||||
|
"</TransInfo>" +
|
||||||
|
"</xml>";
|
||||||
|
m = WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE().kfAccount("test1@test").fromUser("fromuser").toUser("touser").build();
|
||||||
|
m.setCreateTime(1399197672L);
|
||||||
|
System.out.println(m.toXml());
|
||||||
|
Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", ""));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user