大重构:weixin4j精简为weixin4j-base、weixin4j-mp、weixin4j-qy、weixin4j-server四个子工程。
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.foxinmy.weixin4j.mp.event;
|
||||
|
||||
import com.foxinmy.weixin4j.message.event.EventMessage;
|
||||
import com.foxinmy.weixin4j.mp.type.EventType;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
|
||||
/**
|
||||
* 客服关闭会话事件
|
||||
*
|
||||
* @className KfCloseEventMessage
|
||||
* @author jy
|
||||
* @date 2015年3月22日
|
||||
* @since JDK 1.7
|
||||
* @see <a
|
||||
* href="http://mp.weixin.qq.com/wiki/2/6c20f3e323bdf5986cfcb33cbd3b829a.html#.E4.BC.9A.E8.AF.9D.E7.8A.B6.E6.80.81.E9.80.9A.E7.9F.A5.E4.BA.8B.E4.BB.B6">会话状态通知事件</a>
|
||||
*/
|
||||
public class KfCloseEventMessage extends EventMessage {
|
||||
|
||||
private static final long serialVersionUID = 3644449346935205541L;
|
||||
|
||||
public KfCloseEventMessage() {
|
||||
super(EventType.kf_close_session.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* 客服账号
|
||||
*/
|
||||
@XStreamAlias("KfAccount")
|
||||
private String kfAccount;
|
||||
|
||||
public String getKfAccount() {
|
||||
return kfAccount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "KfCloseEventMessage [kfAccount=" + kfAccount + ", ="
|
||||
+ super.toString() + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.foxinmy.weixin4j.mp.event;
|
||||
|
||||
import com.foxinmy.weixin4j.message.event.EventMessage;
|
||||
import com.foxinmy.weixin4j.mp.type.EventType;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
|
||||
/**
|
||||
* 客服接入会话事件
|
||||
*
|
||||
* @className KfCreateEventMessage
|
||||
* @author jy
|
||||
* @date 2015年3月22日
|
||||
* @since JDK 1.7
|
||||
* @see <a
|
||||
* href="http://mp.weixin.qq.com/wiki/2/6c20f3e323bdf5986cfcb33cbd3b829a.html#.E4.BC.9A.E8.AF.9D.E7.8A.B6.E6.80.81.E9.80.9A.E7.9F.A5.E4.BA.8B.E4.BB.B6">会话状态通知事件</a>
|
||||
*/
|
||||
public class KfCreateEventMessage extends EventMessage {
|
||||
|
||||
private static final long serialVersionUID = -8968189700999202108L;
|
||||
|
||||
public KfCreateEventMessage() {
|
||||
super(EventType.kf_create_session.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* 客服账号
|
||||
*/
|
||||
@XStreamAlias("KfAccount")
|
||||
private String kfAccount;
|
||||
|
||||
public String getKfAccount() {
|
||||
return kfAccount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "KfCreateEventMessage [kfAccount=" + kfAccount + ", ="
|
||||
+ super.toString() + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.foxinmy.weixin4j.mp.event;
|
||||
|
||||
import com.foxinmy.weixin4j.message.event.EventMessage;
|
||||
import com.foxinmy.weixin4j.mp.type.EventType;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
|
||||
/**
|
||||
* 客服转接会话事件
|
||||
*
|
||||
* @className KfSwitchEventMessage
|
||||
* @author jy
|
||||
* @date 2015年3月22日
|
||||
* @since JDK 1.7
|
||||
* @see <a
|
||||
* href="http://mp.weixin.qq.com/wiki/2/6c20f3e323bdf5986cfcb33cbd3b829a.html#.E4.BC.9A.E8.AF.9D.E7.8A.B6.E6.80.81.E9.80.9A.E7.9F.A5.E4.BA.8B.E4.BB.B6">会话状态通知事件</a>
|
||||
*/
|
||||
public class KfSwitchEventMessage extends EventMessage {
|
||||
|
||||
private static final long serialVersionUID = 4319501074109623413L;
|
||||
|
||||
public KfSwitchEventMessage() {
|
||||
super(EventType.kf_switch_session.name());
|
||||
}
|
||||
/**
|
||||
* 来自的客服账号
|
||||
*/
|
||||
@XStreamAlias("FromKfAccount")
|
||||
private String fromKfAccount;
|
||||
/**
|
||||
* 转移给客服账号
|
||||
*/
|
||||
@XStreamAlias("ToKfAccount")
|
||||
private String toKfAccount;
|
||||
|
||||
public String getFromKfAccount() {
|
||||
return fromKfAccount;
|
||||
}
|
||||
|
||||
public String getToKfAccount() {
|
||||
return toKfAccount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "KfSwitchEventMessage [fromKfAccount=" + fromKfAccount
|
||||
+ ", toKfAccount=" + toKfAccount + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.foxinmy.weixin4j.mp.event;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.foxinmy.weixin4j.message.event.EventMessage;
|
||||
import com.foxinmy.weixin4j.mp.type.EventType;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
|
||||
/**
|
||||
* 群发消息事件推送
|
||||
*
|
||||
* @className MassEventMessage
|
||||
* @author jy
|
||||
* @date 2014年4月27日
|
||||
* @since JDK 1.7
|
||||
* @see <a
|
||||
* href="http://mp.weixin.qq.com/wiki/15/5380a4e6f02f2ffdc7981a8ed7a40753.html#.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81.E7.BE.A4.E5.8F.91.E7.BB.93.E6.9E.9C">群发回调</a>
|
||||
*/
|
||||
public class MassEventMessage extends EventMessage {
|
||||
|
||||
private static final long serialVersionUID = -1660543255873723895L;
|
||||
|
||||
public MassEventMessage() {
|
||||
super(EventType.masssendjobfinish.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* 群发后的状态信息 为“send success”或“send fail”或“err(num)
|
||||
*/
|
||||
@XStreamAlias("Status")
|
||||
private String status;
|
||||
/**
|
||||
* group_id下粉丝数;或者openid_list中的粉丝数
|
||||
*/
|
||||
@XStreamAlias("TotalCount")
|
||||
private int totalCount;
|
||||
/**
|
||||
* 过滤(过滤是指特定地区、性别的过滤、用户设置拒收的过滤,用户接收已超4条的过滤)后,准备发送的粉丝数,原则上,FilterCount =
|
||||
* SentCount + ErrorCount
|
||||
*/
|
||||
@XStreamAlias("FilterCount")
|
||||
private int filterCount;
|
||||
/**
|
||||
* 发送成功的粉丝数
|
||||
*/
|
||||
@XStreamAlias("SentCount")
|
||||
private int sentCount;
|
||||
/**
|
||||
* 发送失败的粉丝数
|
||||
*/
|
||||
@XStreamAlias("ErrorCount")
|
||||
private int errorCount;
|
||||
|
||||
@XStreamOmitField
|
||||
private final static Map<String, String> statusMap;
|
||||
static {
|
||||
statusMap = new HashMap<String, String>();
|
||||
statusMap.put("sendsuccess", "发送成功");
|
||||
statusMap.put("send_success", "发送成功");
|
||||
statusMap.put("success", "发送成功");
|
||||
statusMap.put("send success", "发送成功");
|
||||
statusMap.put("sendfail", "发送失败");
|
||||
statusMap.put("send_fail", "发送失败");
|
||||
statusMap.put("fail", "发送失败");
|
||||
statusMap.put("send fail", "发送失败");
|
||||
statusMap.put("err(10001)", "涉嫌广告");
|
||||
statusMap.put("err(20001)", "涉嫌政治");
|
||||
statusMap.put("err(20004)", "涉嫌社会");
|
||||
statusMap.put("err(20006)", "涉嫌违法犯罪");
|
||||
statusMap.put("err(20008)", "涉嫌欺诈");
|
||||
statusMap.put("err(20013)", "涉嫌版权");
|
||||
statusMap.put("err(22000)", "涉嫌互推(互相宣传)");
|
||||
statusMap.put("err(21000)", "涉嫌其他");
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送状态描述</br> err(10001,涉嫌广告) err(20001,涉嫌政治) err(20004,涉嫌社会)</br>
|
||||
* err(20002,涉嫌色情) err(20006,涉嫌违法犯罪) err(20008,涉嫌欺诈)</br> err(20013,涉嫌版权)
|
||||
* err(22000,涉嫌互推(互相宣传) err(21000,涉嫌其他)
|
||||
*
|
||||
* @param status
|
||||
* @return 中文描述
|
||||
*/
|
||||
public String getStatusDesc() {
|
||||
return statusMap.get(status.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送状态描述</br> err(10001,涉嫌广告) err(20001,涉嫌政治) err(20004,涉嫌社会)</br>
|
||||
* err(20002,涉嫌色情) err(20006,涉嫌违法犯罪) err(20008,涉嫌欺诈)</br> err(20013,涉嫌版权)
|
||||
* err(22000,涉嫌互推(互相宣传) err(21000,涉嫌其他)
|
||||
*
|
||||
* @param status
|
||||
* @return 中文描述
|
||||
*/
|
||||
public static String getStatusDesc(String status) {
|
||||
return statusMap.get(status.toLowerCase());
|
||||
}
|
||||
|
||||
public int getTotalCount() {
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
public int getFilterCount() {
|
||||
return filterCount;
|
||||
}
|
||||
|
||||
public int getSentCount() {
|
||||
return sentCount;
|
||||
}
|
||||
|
||||
public int getErrorCount() {
|
||||
return errorCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MassEventMessage [status=" + getStatusDesc() + ", totalCount="
|
||||
+ totalCount + ", filterCount=" + filterCount + ", sentCount="
|
||||
+ sentCount + ", errorCount=" + errorCount + ", "
|
||||
+ super.toString() + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.foxinmy.weixin4j.mp.event;
|
||||
|
||||
import com.foxinmy.weixin4j.message.event.EventMessage;
|
||||
import com.foxinmy.weixin4j.mp.type.EventType;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
|
||||
/**
|
||||
* 扫描二维码事件
|
||||
*
|
||||
* @className ScanEventMessage
|
||||
* @author jy.hu
|
||||
* @date 2014年4月6日
|
||||
* @since JDK 1.7
|
||||
* @see <a
|
||||
* href="http://mp.weixin.qq.com/wiki/2/5baf56ce4947d35003b86a9805634b1e.html#.E6.89.AB.E6.8F.8F.E5.B8.A6.E5.8F.82.E6.95.B0.E4.BA.8C.E7.BB.B4.E7.A0.81.E4.BA.8B.E4.BB.B6">扫描二维码事件</a>
|
||||
*/
|
||||
public class ScanEventMessage extends EventMessage {
|
||||
|
||||
private static final long serialVersionUID = 8078674062833071562L;
|
||||
|
||||
public ScanEventMessage() {
|
||||
super(EventType.scan.name());
|
||||
}
|
||||
|
||||
public ScanEventMessage(String eventType) {
|
||||
super(eventType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件KEY值,是一个32位无符号整数,即创建二维码时的二维码scene_id
|
||||
*/
|
||||
@XStreamAlias("EventKey")
|
||||
private String eventKey;
|
||||
/**
|
||||
* 二维码的ticket,可用来换取二维码图片
|
||||
*/
|
||||
@XStreamAlias("Ticket")
|
||||
private String ticket;
|
||||
|
||||
public String getEventKey() {
|
||||
return eventKey;
|
||||
}
|
||||
|
||||
public String getTicket() {
|
||||
return ticket;
|
||||
}
|
||||
|
||||
public String getParameter() {
|
||||
return eventKey.replace("qrscene_", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ScanEventMessage [eventKey=" + eventKey + ", ticket=" + ticket
|
||||
+ ", " + super.toString() + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.foxinmy.weixin4j.mp.event;
|
||||
|
||||
import com.foxinmy.weixin4j.type.EventType;
|
||||
|
||||
/**
|
||||
* 关注/取消关注事件</br> <font color="red">包括直接关注与扫描关注</font>
|
||||
*
|
||||
* @className ScribeEventMessage
|
||||
* @author jy.hu
|
||||
* @date 2014年4月6日
|
||||
* @since JDK 1.7
|
||||
* @see <a
|
||||
* href="http://mp.weixin.qq.com/wiki/2/5baf56ce4947d35003b86a9805634b1e.html#.E5.85.B3.E6.B3.A8.2F.E5.8F.96.E6.B6.88.E5.85.B3.E6.B3.A8.E4.BA.8B.E4.BB.B6">订阅号、服务号的关注/取消关注事件</a>
|
||||
*/
|
||||
public class ScribeEventMessage extends ScanEventMessage {
|
||||
|
||||
private static final long serialVersionUID = -6846321620262204915L;
|
||||
|
||||
public ScribeEventMessage() {
|
||||
super(EventType.subscribe.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ScribeEventMessage [" + super.toString() + "]";
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.foxinmy.weixin4j.mp.event;
|
||||
|
||||
import com.foxinmy.weixin4j.message.event.EventMessage;
|
||||
import com.foxinmy.weixin4j.mp.type.EventType;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
|
||||
/**
|
||||
* 模板消息事件推送(公众平台)
|
||||
*
|
||||
* @className TemplatesendjobfinishMessage
|
||||
* @author jy
|
||||
* @date 2014年9月19日
|
||||
* @since JDK 1.7
|
||||
* @see <a
|
||||
* href="http://mp.weixin.qq.com/wiki/17/304c1885ea66dbedf7dc170d84999a9d.html#.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81">模板消息事件推送</a>
|
||||
*/
|
||||
public class TemplatesendjobfinishMessage extends EventMessage {
|
||||
|
||||
private static final long serialVersionUID = -2903359365988594012L;
|
||||
|
||||
public TemplatesendjobfinishMessage() {
|
||||
super(EventType.templatesendjobfinish.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送状态 如failed: system failed
|
||||
*/
|
||||
@XStreamAlias("Status")
|
||||
private String status;
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TemplatesendjobfinishMessage [status=" + status + ", "
|
||||
+ super.toString() + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package com.foxinmy.weixin4j.mp.model;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.foxinmy.weixin4j.model.WeixinAccount;
|
||||
|
||||
/**
|
||||
* 微信公众平台信息
|
||||
*
|
||||
* @className WeixinMpAccount
|
||||
* @author jy
|
||||
* @date 2014年8月17日
|
||||
* @since JDK 1.7
|
||||
* @see <a href=
|
||||
* "https://mp.weixin.qq.com/advanced/advanced?action=dev&t=advanced/dev&token=836970804&lang=zh_CN"
|
||||
* >开发者模式</a>
|
||||
*/
|
||||
public class WeixinMpAccount extends WeixinAccount {
|
||||
private static final long serialVersionUID = 3689999353867189585L;
|
||||
|
||||
/**
|
||||
* 支付场景下为用户的openid 其余情况可能是公众号的原始ID
|
||||
*/
|
||||
private String openId;
|
||||
/**
|
||||
* 公众号支付请求中用于加密的密钥 Key,可验证商户唯一身份,PaySignKey 对应于支付场景中的 appKey 值
|
||||
*/
|
||||
private String paySignKey;
|
||||
/**
|
||||
* 财付通商户身份的标识
|
||||
*/
|
||||
private String partnerId;
|
||||
/**
|
||||
* 财付通商户权限密钥Key
|
||||
*/
|
||||
private String partnerKey;
|
||||
/**
|
||||
* 微信支付分配的商户号(商户平台版)
|
||||
*/
|
||||
private String mchId;
|
||||
/**
|
||||
* 微信支付分配的子商户号,受理模式下必填(商户平台版)
|
||||
*/
|
||||
private String subMchId;
|
||||
/**
|
||||
* 微信支付分配的设备号(商户平台版)
|
||||
*/
|
||||
private String deviceInfo;
|
||||
/**
|
||||
* 微信支付版本号(如果无则按照mchId来做判断)
|
||||
*/
|
||||
private int version;
|
||||
|
||||
public String getOpenId() {
|
||||
return openId;
|
||||
}
|
||||
|
||||
public void setOpenId(String openId) {
|
||||
this.openId = openId;
|
||||
}
|
||||
|
||||
public String getPaySignKey() {
|
||||
return paySignKey;
|
||||
}
|
||||
|
||||
public void setPaySignKey(String paySignKey) {
|
||||
this.paySignKey = paySignKey;
|
||||
}
|
||||
|
||||
public String getPartnerId() {
|
||||
return partnerId;
|
||||
}
|
||||
|
||||
public void setPartnerId(String partnerId) {
|
||||
this.partnerId = partnerId;
|
||||
}
|
||||
|
||||
public String getPartnerKey() {
|
||||
return partnerKey;
|
||||
}
|
||||
|
||||
public void setPartnerKey(String partnerKey) {
|
||||
this.partnerKey = partnerKey;
|
||||
}
|
||||
|
||||
public String getMchId() {
|
||||
return mchId;
|
||||
}
|
||||
|
||||
public void setMchId(String mchId) {
|
||||
this.mchId = mchId;
|
||||
}
|
||||
|
||||
public String getDeviceInfo() {
|
||||
return deviceInfo;
|
||||
}
|
||||
|
||||
public void setDeviceInfo(String deviceInfo) {
|
||||
this.deviceInfo = deviceInfo;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
if (version == 0) {
|
||||
return StringUtils.isNotBlank(mchId) ? 3 : 2;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getSubMchId() {
|
||||
return subMchId;
|
||||
}
|
||||
|
||||
public void setSubMchId(String subMchId) {
|
||||
this.subMchId = subMchId;
|
||||
}
|
||||
|
||||
public WeixinMpAccount() {
|
||||
|
||||
}
|
||||
|
||||
public WeixinMpAccount(String appId, String appSecret) {
|
||||
super(appId, appSecret);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商户平台版本(V3)字段
|
||||
*
|
||||
* @param appId
|
||||
* 公众号唯一的身份ID
|
||||
* @param appSecret
|
||||
* 调用接口的凭证
|
||||
* @param paySignKey
|
||||
* 支付密钥字符串
|
||||
* @param mchId
|
||||
* 微信支付分配的商户号
|
||||
*/
|
||||
public WeixinMpAccount(String appId, String appSecret, String paySignKey,
|
||||
String mchId) {
|
||||
this(appId, appSecret);
|
||||
this.paySignKey = paySignKey;
|
||||
this.mchId = mchId;
|
||||
}
|
||||
|
||||
/**
|
||||
* V2版本字段
|
||||
*
|
||||
* @param appId
|
||||
* 公众号唯一的身份ID
|
||||
* @param appSecret
|
||||
* 调用接口的凭证
|
||||
* @param paySignKey
|
||||
* 支付密钥字符串
|
||||
* @param partnerId
|
||||
* 财付通账号的ID
|
||||
* @param partnerKey
|
||||
* 财付通账号的key
|
||||
*/
|
||||
public WeixinMpAccount(String appId, String appSecret, String paySignKey,
|
||||
String partnerId, String partnerKey) {
|
||||
this(appId, appSecret);
|
||||
this.paySignKey = paySignKey;
|
||||
this.partnerId = partnerId;
|
||||
this.partnerKey = partnerKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WeixinMpAccount [openId=" + openId + ", paySignKey="
|
||||
+ paySignKey + ", partnerId=" + partnerId + ", partnerKey="
|
||||
+ partnerKey + ", mchId=" + mchId + ", deviceInfo="
|
||||
+ deviceInfo + ", version=" + version + ", " + super.toString()
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user