发送客服消息接口支持以某个客服的名义发送消息

This commit is contained in:
Binary Wang
2016-07-19 15:32:12 +08:00
parent ff801044c2
commit b88560d9af
3 changed files with 29 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ public class WxMpCustomMessage implements Serializable {
private String description;
private String musicUrl;
private String hqMusicUrl;
private String kfAccount;
private List<WxArticle> articles = new ArrayList<>();
public String getToUser() {
@@ -180,4 +181,12 @@ public class WxMpCustomMessage implements Serializable {
return new NewsBuilder();
}
public String getKfAccount() {
return kfAccount;
}
public void setKfAccount(String kfAccount) {
this.kfAccount = kfAccount;
}
}

View File

@@ -14,6 +14,8 @@ import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
import java.lang.reflect.Type;
import org.apache.commons.lang3.StringUtils;
public class WxMpCustomMessageGsonAdapter implements JsonSerializer<WxMpCustomMessage> {
public JsonElement serialize(WxMpCustomMessage message, Type typeOfSrc, JsonSerializationContext context) {
@@ -73,6 +75,12 @@ public class WxMpCustomMessageGsonAdapter implements JsonSerializer<WxMpCustomMe
messageJson.add("news", newsJsonObject);
}
if (StringUtils.isNotBlank(message.getKfAccount())){
JsonObject newsJsonObject = new JsonObject();
newsJsonObject.addProperty("kf_account", message.getKfAccount());
messageJson.add("customservice", newsJsonObject);
}
return messageJson;
}