mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-23 22:11:40 +08:00
Merge pull request #41 from mgcnrx11/feat-custom-msg-wxcard
新增卡券的客服消息类型
This commit is contained in:
commit
54ab159371
@ -30,6 +30,7 @@ public class WxConsts {
|
|||||||
public static final String CUSTOM_MSG_MUSIC = "music";
|
public static final String CUSTOM_MSG_MUSIC = "music";
|
||||||
public static final String CUSTOM_MSG_NEWS = "news";
|
public static final String CUSTOM_MSG_NEWS = "news";
|
||||||
public static final String CUSTOM_MSG_FILE = "file";
|
public static final String CUSTOM_MSG_FILE = "file";
|
||||||
|
public static final String CUSTOM_MSG_WXCARD = "wxcard";
|
||||||
public static final String CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service";
|
public static final String CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service";
|
||||||
public static final String CUSTOM_MSG_SAFE_NO = "0";
|
public static final String CUSTOM_MSG_SAFE_NO = "0";
|
||||||
public static final String CUSTOM_MSG_SAFE_YES = "1";
|
public static final String CUSTOM_MSG_SAFE_YES = "1";
|
||||||
|
@ -25,6 +25,7 @@ public class WxMpCustomMessage implements Serializable {
|
|||||||
private String musicUrl;
|
private String musicUrl;
|
||||||
private String hqMusicUrl;
|
private String hqMusicUrl;
|
||||||
private String kfAccount;
|
private String kfAccount;
|
||||||
|
private String cardId;
|
||||||
private List<WxArticle> articles = new ArrayList<>();
|
private List<WxArticle> articles = new ArrayList<>();
|
||||||
|
|
||||||
public String getToUser() {
|
public String getToUser() {
|
||||||
@ -46,6 +47,7 @@ public class WxMpCustomMessage implements Serializable {
|
|||||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MUSIC}
|
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MUSIC}
|
||||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VIDEO}
|
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VIDEO}
|
||||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_NEWS}
|
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_NEWS}
|
||||||
|
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_WXCARD}
|
||||||
* </pre>
|
* </pre>
|
||||||
* @param msgType
|
* @param msgType
|
||||||
*/
|
*/
|
||||||
@ -94,6 +96,15 @@ public class WxMpCustomMessage implements Serializable {
|
|||||||
public void setHqMusicUrl(String hqMusicUrl) {
|
public void setHqMusicUrl(String hqMusicUrl) {
|
||||||
this.hqMusicUrl = hqMusicUrl;
|
this.hqMusicUrl = hqMusicUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCardId() {
|
||||||
|
return cardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCardId(String cardId) {
|
||||||
|
this.cardId = cardId;
|
||||||
|
}
|
||||||
|
|
||||||
public List<WxArticle> getArticles() {
|
public List<WxArticle> getArticles() {
|
||||||
return this.articles;
|
return this.articles;
|
||||||
}
|
}
|
||||||
@ -181,6 +192,15 @@ public class WxMpCustomMessage implements Serializable {
|
|||||||
return new NewsBuilder();
|
return new NewsBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得卡券消息builder
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static WxCardBuilder WXCARD() {
|
||||||
|
return new WxCardBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
public String getKfAccount() {
|
public String getKfAccount() {
|
||||||
return this.kfAccount;
|
return this.kfAccount;
|
||||||
}
|
}
|
||||||
@ -188,5 +208,4 @@ public class WxMpCustomMessage implements Serializable {
|
|||||||
public void setKfAccount(String kfAccount) {
|
public void setKfAccount(String kfAccount) {
|
||||||
this.kfAccount = kfAccount;
|
this.kfAccount = kfAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package me.chanjar.weixin.mp.bean.custombuilder;
|
||||||
|
|
||||||
|
import me.chanjar.weixin.common.api.WxConsts;
|
||||||
|
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 卡券消息builder
|
||||||
|
* <pre>
|
||||||
|
* 用法: WxMpCustomMessage m = WxMpCustomMessage.WXCARD().cardId(...).toUser(...).build();
|
||||||
|
* </pre>
|
||||||
|
* @author mgcnrx11
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final class WxCardBuilder extends BaseBuilder<WxCardBuilder> {
|
||||||
|
private String cardId;
|
||||||
|
|
||||||
|
public WxCardBuilder() {
|
||||||
|
this.msgType = WxConsts.CUSTOM_MSG_WXCARD;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WxCardBuilder cardId(String cardId) {
|
||||||
|
this.cardId = cardId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WxMpCustomMessage build() {
|
||||||
|
WxMpCustomMessage m = super.build();
|
||||||
|
m.setCardId(this.cardId);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
}
|
@ -76,6 +76,12 @@ public class WxMpCustomMessageGsonAdapter implements JsonSerializer<WxMpCustomMe
|
|||||||
messageJson.add("news", newsJsonObject);
|
messageJson.add("news", newsJsonObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (WxConsts.CUSTOM_MSG_WXCARD.equals(message.getMsgType())) {
|
||||||
|
JsonObject wxcard = new JsonObject();
|
||||||
|
wxcard.addProperty("card_id", message.getCardId());
|
||||||
|
messageJson.add("wxcard", wxcard);
|
||||||
|
}
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(message.getKfAccount())){
|
if (StringUtils.isNotBlank(message.getKfAccount())){
|
||||||
JsonObject newsJsonObject = new JsonObject();
|
JsonObject newsJsonObject = new JsonObject();
|
||||||
newsJsonObject.addProperty("kf_account", message.getKfAccount());
|
newsJsonObject.addProperty("kf_account", message.getKfAccount());
|
||||||
|
Loading…
Reference in New Issue
Block a user