From 8de51e5e25a728de80ca8fac1cbc86ea74bdffda Mon Sep 17 00:00:00 2001 From: hxf Date: Thu, 6 Jun 2024 16:30:47 +0800 Subject: [PATCH] =?UTF-8?q?weixin-java-channel=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E4=BA=AB=E5=91=98=E5=8F=98=E6=9B=B4=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/BaseWxChannelMessageService.java | 13 +++++ .../impl/BaseWxChannelMessageServiceImpl.java | 9 ++++ .../message/sharer/SharerChangeMessage.java | 47 +++++++++++++++++++ .../constant/MessageEventConstants.java | 4 ++ 4 files changed, 73 insertions(+) create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/sharer/SharerChangeMessage.java diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/BaseWxChannelMessageService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/BaseWxChannelMessageService.java index 5a1ecce58..a4a2c4240 100644 --- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/BaseWxChannelMessageService.java +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/BaseWxChannelMessageService.java @@ -433,4 +433,17 @@ public interface BaseWxChannelMessageService { */ Object defaultMessageHandler(WxChannelMessage message, final String content, final String appId, final Map context, final WxSessionManager sessionManager); + + + /** + * 分享员变更 + * + * @param message the message + * @param content the content + * @param appId the app id + * @param context the context + * @param sessionManager the session manager + */ + void sharerChange(WxChannelMessage message, final String content, final String appId, + final Map context, final WxSessionManager sessionManager); } diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelMessageServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelMessageServiceImpl.java index 2cc75d0de..46837deba 100644 --- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelMessageServiceImpl.java +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelMessageServiceImpl.java @@ -23,6 +23,7 @@ import me.chanjar.weixin.channel.bean.message.order.OrderStatusMessage; import me.chanjar.weixin.channel.bean.message.product.BrandMessage; import me.chanjar.weixin.channel.bean.message.product.CategoryAuditMessage; import me.chanjar.weixin.channel.bean.message.product.SpuAuditMessage; +import me.chanjar.weixin.channel.bean.message.sharer.SharerChangeMessage; import me.chanjar.weixin.channel.bean.message.supplier.SupplierItemMessage; import me.chanjar.weixin.channel.bean.message.vip.ExchangeInfoMessage; import me.chanjar.weixin.channel.bean.message.vip.UserInfoMessage; @@ -121,6 +122,10 @@ public abstract class BaseWxChannelMessageServiceImpl implements BaseWxChannelMe this.addRule(UserInfoMessage.class, USER_VIP_SCORE_UPDATE, false, this::vipScoreUpdate); /* 用户积分兑换 */ this.addRule(ExchangeInfoMessage.class, USER_VIP_SCORE_EXCHANGE, false, this::vipScoreExchange); + + + /* 分享员变更 */ + this.addRule(SharerChangeMessage.class,SHARER_CHANGE,false,this::sharerChange); } /** @@ -333,6 +338,10 @@ public abstract class BaseWxChannelMessageServiceImpl implements BaseWxChannelMe return null; } + @Override + public void sharerChange(WxChannelMessage message, String content, String appId, Map context, WxSessionManager sessionManager) { + log.info("分享员变更:{}", JsonUtils.encode(message)); + } @Override public abstract void vipJoin(UserInfoMessage message, String content, String appId, diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/sharer/SharerChangeMessage.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/sharer/SharerChangeMessage.java new file mode 100644 index 000000000..ac997aeb4 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/message/sharer/SharerChangeMessage.java @@ -0,0 +1,47 @@ +package me.chanjar.weixin.channel.bean.message.sharer; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.message.WxChannelMessage; + +/** + * 分享员变更消息 + * https://developers.weixin.qq.com/doc/channels/API/sharer/callback/channels_ec_sharer_change.html + * + * @author sd-hxf + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JacksonXmlRootElement(localName = "xml") +public class SharerChangeMessage extends WxChannelMessage { + + private static final long serialVersionUID = 4219477394934480421L; + + /** + * 分享员OpenID + */ + @JsonProperty("openid") + @JacksonXmlProperty(localName = "openid") + private String openid; + + /** + * 分享员类型:0-普通分享员,1-店铺分享员 + */ + @JsonProperty("sharer_type") + @JacksonXmlProperty(localName = "sharer_type") + private Integer sharerType; + + /** + * 分享员绑定状态:1-绑定,2-解绑 + */ + @JsonProperty("bind_status") + @JacksonXmlProperty(localName = "bind_status") + private String bindStatus; + + +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/MessageEventConstants.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/MessageEventConstants.java index f1e445513..48cf268b0 100644 --- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/MessageEventConstants.java +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/MessageEventConstants.java @@ -79,4 +79,8 @@ public interface MessageEventConstants { String USER_VIP_SCORE_UPDATE = "channels_ec_vip_score_update"; /** 用户积分兑换 */ String USER_VIP_SCORE_EXCHANGE = "channels_ec_vip_score_exchange"; + + // 分享员相关 + /** 分享员变更 **/ + String SHARER_CHANGE = "channels_ec_sharer_change"; } -- Gitee