- * 消息重复检查器 + * 消息重复检查器. * 微信服务器在五秒内收不到响应会断掉连接,并且重新发起请求,总共重试三次 **/ public interface WxMessageDuplicateChecker { /** + * 判断消息是否重复. *
+ * *
普通消息:关于重试的消息排重,推荐使用msgid排重。文档参考。
*事件消息:关于重试的消息排重,推荐使用FromUserName + CreateTime 排重。文档参考
- *+ * *
- * 官方文档完全没有写,参照公众号的方式排重。 - *
+ *
官方文档完全没有写,参照公众号的方式排重。
*或者可以采取更简单的方式,如果有MsgId就用MsgId排重,如果没有就用FromUserName+CreateTime排重
* * @param messageId messageId需要根据上面讲的方式构造 diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateChecker.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateChecker.java index 1281e26012..d8be08f446 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateChecker.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateChecker.java @@ -6,46 +6,46 @@ /** *- * 默认消息重复检查器 + * 默认消息重复检查器. * 将每个消息id保存在内存里,每隔5秒清理已经过期的消息id,每个消息id的过期时间是15秒 **/ public class WxMessageInMemoryDuplicateChecker implements WxMessageDuplicateChecker { /** - * 一个消息ID在内存的过期时间:15秒 + * 一个消息ID在内存的过期时间:15秒. */ private final Long timeToLive; /** - * 每隔多少周期检查消息ID是否过期:5秒 + * 每隔多少周期检查消息ID是否过期:5秒. */ private final Long clearPeriod; /** - * 消息id->消息时间戳的map + * 消息id->消息时间戳的map. */ private final ConcurrentHashMap
* 一个消息ID在内存的过期时间:15秒
* 每隔多少周期检查消息ID是否过期:5秒
*
*/
public WxMessageInMemoryDuplicateChecker() {
- this.timeToLive = 15 * 1000l;
- this.clearPeriod = 5 * 1000l;
+ this.timeToLive = 15 * 1000L;
+ this.clearPeriod = 5 * 1000L;
}
/**
- * WxMsgIdInMemoryDuplicateChecker构造函数
+ * 构造方法.
*
* @param timeToLive 一个消息ID在内存的过期时间:毫秒
* @param clearPeriod 每隔多少周期检查消息ID是否过期:毫秒
@@ -66,7 +66,8 @@ public void run() {
while (true) {
Thread.sleep(WxMessageInMemoryDuplicateChecker.this.clearPeriod);
Long now = System.currentTimeMillis();
- for (Map.Entry
- * 菜单的响应动作类型:
+ * 菜单的响应动作类型.
* view表示网页类型,
* click表示点击类型,
* miniprogram表示小程序类型
@@ -21,13 +23,13 @@ public class WxMenuButton implements Serializable {
private String type;
/**
- * 菜单标题,不超过16个字节,子菜单不超过60个字节
+ * 菜单标题,不超过16个字节,子菜单不超过60个字节.
*/
private String name;
/**
*
- * 菜单KEY值,用于消息接口推送,不超过128字节
+ * 菜单KEY值,用于消息接口推送,不超过128字节.
* click等点击类型必须
*
*/
@@ -35,7 +37,8 @@ public class WxMenuButton implements Serializable {
/**
*
- * 网页链接,用户点击菜单可打开链接,不超过1024字节。type为miniprogram时,不支持小程序的老版本客户端将打开本url。
+ * 网页链接.
+ * 用户点击菜单可打开链接,不超过1024字节。type为miniprogram时,不支持小程序的老版本客户端将打开本url。
* view、miniprogram类型必须
*
*/
@@ -43,7 +46,7 @@ public class WxMenuButton implements Serializable {
/**
*
- * 调用新增永久素材接口返回的合法media_id
+ * 调用新增永久素材接口返回的合法media_id.
* media_id类型和view_limited类型必须
*
*/
@@ -52,7 +55,7 @@ public class WxMenuButton implements Serializable {
/**
*
- * 小程序的appid
+ * 小程序的appid.
* miniprogram类型必须
*
*/
@@ -61,7 +64,7 @@ public class WxMenuButton implements Serializable {
/**
*
- * 小程序的页面路径
+ * 小程序的页面路径.
* miniprogram类型必须
*
*/
@@ -76,67 +79,4 @@ public String toString() {
return ToStringUtils.toSimpleString(this);
}
- public String getType() {
- return this.type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getKey() {
- return this.key;
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
- public String getUrl() {
- return this.url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public List getSubButtons() {
- return this.subButtons;
- }
-
- public void setSubButtons(List subButtons) {
- this.subButtons = subButtons;
- }
-
- public String getMediaId() {
- return this.mediaId;
- }
-
- public void setMediaId(String mediaId) {
- this.mediaId = mediaId;
- }
-
- public String getAppId() {
- return appId;
- }
-
- public void setAppId(String appId) {
- this.appId = appId;
- }
-
- public String getPagePath() {
- return pagePath;
- }
-
- public void setPagePath(String pagePath) {
- this.pagePath = pagePath;
- }
}
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java
index e0182c9678..16542dec69 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java
@@ -1,12 +1,19 @@
package me.chanjar.weixin.common.bean.menu;
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
import me.chanjar.weixin.common.util.ToStringUtils;
import java.io.Serializable;
+@Data
public class WxMenuRule implements Serializable {
private static final long serialVersionUID = -4587181819499286670L;
+ /**
+ * 变态的微信接口,反序列化时这里反人类的使用和序列化时不一样的名字.
+ */
+ @SerializedName(value = "tag_id", alternate = "group_id")
private String tagId;
private String sex;
private String country;
@@ -15,62 +22,6 @@ public class WxMenuRule implements Serializable {
private String clientPlatformType;
private String language;
- public String getTagId() {
- return this.tagId;
- }
-
- public void setTagId(String tagId) {
- this.tagId = tagId;
- }
-
- public String getSex() {
- return this.sex;
- }
-
- public void setSex(String sex) {
- this.sex = sex;
- }
-
- public String getCountry() {
- return this.country;
- }
-
- public void setCountry(String country) {
- this.country = country;
- }
-
- public String getProvince() {
- return this.province;
- }
-
- public void setProvince(String province) {
- this.province = province;
- }
-
- public String getCity() {
- return this.city;
- }
-
- public void setCity(String city) {
- this.city = city;
- }
-
- public String getClientPlatformType() {
- return this.clientPlatformType;
- }
-
- public void setClientPlatformType(String clientPlatformType) {
- this.clientPlatformType = clientPlatformType;
- }
-
- public String getLanguage() {
- return this.language;
- }
-
- public void setLanguage(String language) {
- this.language = language;
- }
-
@Override
public String toString() {
return ToStringUtils.toSimpleString(this);
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java
index 46c0ae89be..25a06f4785 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java
@@ -1,14 +1,18 @@
package me.chanjar.weixin.common.bean.result;
+import lombok.Builder;
+import lombok.Data;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;
/**
- * 微信错误码说明,请阅读: 全局返回码说明
+ * 微信错误码说明,请阅读: 全局返回码说明.
*
* @author Daniel Qian
*/
+@Data
+@Builder
public class WxError implements Serializable {
private static final long serialVersionUID = 7869786563361406291L;
@@ -23,34 +27,6 @@ public static WxError fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxError.class);
}
- public static Builder newBuilder() {
- return new Builder();
- }
-
- public int getErrorCode() {
- return this.errorCode;
- }
-
- public void setErrorCode(int errorCode) {
- this.errorCode = errorCode;
- }
-
- public String getErrorMsg() {
- return this.errorMsg;
- }
-
- public void setErrorMsg(String errorMsg) {
- this.errorMsg = errorMsg;
- }
-
- public String getJson() {
- return this.json;
- }
-
- public void setJson(String json) {
- this.json = json;
- }
-
@Override
public String toString() {
if (this.json != null) {
@@ -59,26 +35,4 @@ public String toString() {
return "错误: Code=" + this.errorCode + ", Msg=" + this.errorMsg;
}
- public static class Builder {
- private int errorCode;
- private String errorMsg;
-
- public Builder setErrorCode(int errorCode) {
- this.errorCode = errorCode;
- return this;
- }
-
- public Builder setErrorMsg(String errorMsg) {
- this.errorMsg = errorMsg;
- return this;
- }
-
- public WxError build() {
- WxError wxError = new WxError();
- wxError.setErrorCode(this.errorCode);
- wxError.setErrorMsg(this.errorMsg);
- return wxError;
- }
-
- }
}
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMediaUploadResult.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMediaUploadResult.java
index 706de712c7..a50018aaef 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMediaUploadResult.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMediaUploadResult.java
@@ -1,11 +1,12 @@
package me.chanjar.weixin.common.bean.result;
+import lombok.Data;
+import me.chanjar.weixin.common.util.ToStringUtils;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
import java.io.Serializable;
+@Data
public class WxMediaUploadResult implements Serializable {
private static final long serialVersionUID = 330834334738622341L;
@@ -18,41 +19,9 @@ public static WxMediaUploadResult fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxMediaUploadResult.class);
}
- public String getType() {
- return this.type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getMediaId() {
- return this.mediaId;
- }
-
- public void setMediaId(String mediaId) {
- this.mediaId = mediaId;
- }
-
- public long getCreatedAt() {
- return this.createdAt;
- }
-
- public void setCreatedAt(long createdAt) {
- this.createdAt = createdAt;
- }
-
- public String getThumbMediaId() {
- return this.thumbMediaId;
- }
-
- public void setThumbMediaId(String thumbMediaId) {
- this.thumbMediaId = thumbMediaId;
- }
-
@Override
public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
+ return ToStringUtils.toSimpleString(this);
}
}
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java
index 630821e954..12ce3a4e13 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java
@@ -11,6 +11,7 @@
import org.slf4j.LoggerFactory;
import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -20,8 +21,9 @@
*
* bean操作的一些工具类
* Created by Binary Wang on 2016-10-21.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author binarywang(Binary Wang)
*/
public class BeanUtils {
private static Logger log = LoggerFactory.getLogger(BeanUtils.class);
@@ -42,22 +44,27 @@ public static void checkRequiredFields(Object bean) throws WxErrorException {
boolean isAccessible = field.isAccessible();
field.setAccessible(true);
if (field.isAnnotationPresent(Required.class)) {
- if (field.get(bean) == null || (field.get(bean) instanceof String && StringUtils.isBlank(field.get(bean).toString()))) {
- //两种情况,一种是值为null,另外一种情况是类型为字符串,但是字符串内容为空的,都认为是没有提供值
+ // 两种情况,一种是值为null,
+ // 另外一种情况是类型为字符串,但是字符串内容为空的,都认为是没有提供值
+ boolean isRequiredMissing = field.get(bean) == null
+ || (field.get(bean) instanceof String
+ && StringUtils.isBlank(field.get(bean).toString())
+ );
+ if (isRequiredMissing) {
requiredFields.add(field.getName());
}
}
field.setAccessible(isAccessible);
} catch (SecurityException | IllegalArgumentException
| IllegalAccessException e) {
- e.printStackTrace();
+ log.error(e.getMessage(), e);
}
}
if (!requiredFields.isEmpty()) {
String msg = "必填字段 " + requiredFields + " 必须提供值";
log.debug(msg);
- throw new WxErrorException(WxError.newBuilder().setErrorMsg(msg).build());
+ throw new WxErrorException(WxError.builder().errorMsg(msg).build());
}
}
@@ -82,11 +89,14 @@ public static Map xmlBean2Map(Object bean) {
if (field.isAnnotationPresent(XStreamAlias.class)) {
result.put(field.getAnnotation(XStreamAlias.class).value(), field.get(bean).toString());
+ } else if (!Modifier.isStatic(field.getModifiers())) {
+ //忽略掉静态成员变量
+ result.put(field.getName(), field.get(bean).toString());
}
field.setAccessible(isAccessible);
} catch (SecurityException | IllegalArgumentException | IllegalAccessException e) {
- e.printStackTrace();
+ log.error(e.getMessage(), e);
}
}
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/ToStringUtils.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/ToStringUtils.java
index 333e484a8f..a0b069d166 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/ToStringUtils.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/ToStringUtils.java
@@ -8,8 +8,9 @@
*
* 自定义的ToString方法,用于产生去掉空值属性的字符串
* Created by Binary Wang on 2016-10-27.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
public class ToStringUtils {
public static final ToStringStyle THE_STYLE = new SimpleMultiLineToStringStyle();
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/ByteGroup.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/ByteGroup.java
index b12ec65555..bff08d680d 100755
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/ByteGroup.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/ByteGroup.java
@@ -1,26 +1,26 @@
-package me.chanjar.weixin.common.util.crypto;
-
-import java.util.ArrayList;
-
-public class ByteGroup {
- ArrayList byteContainer = new ArrayList<>();
-
- public byte[] toBytes() {
- byte[] bytes = new byte[this.byteContainer.size()];
- for (int i = 0; i < this.byteContainer.size(); i++) {
- bytes[i] = this.byteContainer.get(i);
- }
- return bytes;
- }
-
- public ByteGroup addBytes(byte[] bytes) {
- for (byte b : bytes) {
- this.byteContainer.add(b);
- }
- return this;
- }
-
- public int size() {
- return this.byteContainer.size();
- }
-}
+package me.chanjar.weixin.common.util.crypto;
+
+import java.util.ArrayList;
+
+public class ByteGroup {
+ ArrayList byteContainer = new ArrayList<>();
+
+ public byte[] toBytes() {
+ byte[] bytes = new byte[this.byteContainer.size()];
+ for (int i = 0; i < this.byteContainer.size(); i++) {
+ bytes[i] = this.byteContainer.get(i);
+ }
+ return bytes;
+ }
+
+ public ByteGroup addBytes(byte[] bytes) {
+ for (byte b : bytes) {
+ this.byteContainer.add(b);
+ }
+ return this;
+ }
+
+ public int size() {
+ return this.byteContainer.size();
+ }
+}
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/PKCS7Encoder.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/PKCS7Encoder.java
index 145896a577..8ce94cbac0 100755
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/PKCS7Encoder.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/PKCS7Encoder.java
@@ -1,68 +1,68 @@
-/**
- * 对公众平台发送给公众账号的消息加解密示例代码.
- *
- * @copyright Copyright (c) 1998-2014 Tencent Inc.
- */
-
-// ------------------------------------------------------------------------
-
-package me.chanjar.weixin.common.util.crypto;
-
-import java.nio.charset.Charset;
-import java.util.Arrays;
-
-/**
- * 提供基于PKCS7算法的加解
- */
-public class PKCS7Encoder {
-
- private static final Charset CHARSET = Charset.forName("utf-8");
- private static final int BLOCK_SIZE = 32;
-
- /**
- * 获得对明文进行补位填充的字节.
- *
- * @param count 需要进行填充补位操作的明文字节个数
- * @return 补齐用的字节数组
- */
- public static byte[] encode(int count) {
- // 计算需要填充的位数
- int amountToPad = BLOCK_SIZE - (count % BLOCK_SIZE);
- if (amountToPad == 0) {
- amountToPad = BLOCK_SIZE;
- }
- // 获得补位所用的字符
- char padChr = chr(amountToPad);
- String tmp = new String();
- for (int index = 0; index < amountToPad; index++) {
- tmp += padChr;
- }
- return tmp.getBytes(CHARSET);
- }
-
- /**
- * 删除解密后明文的补位字符
- *
- * @param decrypted 解密后的明文
- * @return 删除补位字符后的明文
- */
- public static byte[] decode(byte[] decrypted) {
- int pad = decrypted[decrypted.length - 1];
- if (pad < 1 || pad > 32) {
- pad = 0;
- }
- return Arrays.copyOfRange(decrypted, 0, decrypted.length - pad);
- }
-
- /**
- * 将数字转化成ASCII码对应的字符,用于对明文进行补码
- *
- * @param a 需要转化的数字
- * @return 转化得到的字符
- */
- public static char chr(int a) {
- byte target = (byte) (a & 0xFF);
- return (char) target;
- }
-
-}
+/**
+ * 对公众平台发送给公众账号的消息加解密示例代码.
+ *
+ * @copyright Copyright (c) 1998-2014 Tencent Inc.
+ */
+
+// ------------------------------------------------------------------------
+
+package me.chanjar.weixin.common.util.crypto;
+
+import java.nio.charset.Charset;
+import java.util.Arrays;
+
+/**
+ * 提供基于PKCS7算法的加解
+ */
+public class PKCS7Encoder {
+
+ private static final Charset CHARSET = Charset.forName("utf-8");
+ private static final int BLOCK_SIZE = 32;
+
+ /**
+ * 获得对明文进行补位填充的字节.
+ *
+ * @param count 需要进行填充补位操作的明文字节个数
+ * @return 补齐用的字节数组
+ */
+ public static byte[] encode(int count) {
+ // 计算需要填充的位数
+ int amountToPad = BLOCK_SIZE - (count % BLOCK_SIZE);
+ if (amountToPad == 0) {
+ amountToPad = BLOCK_SIZE;
+ }
+ // 获得补位所用的字符
+ char padChr = chr(amountToPad);
+ String tmp = new String();
+ for (int index = 0; index < amountToPad; index++) {
+ tmp += padChr;
+ }
+ return tmp.getBytes(CHARSET);
+ }
+
+ /**
+ * 删除解密后明文的补位字符
+ *
+ * @param decrypted 解密后的明文
+ * @return 删除补位字符后的明文
+ */
+ public static byte[] decode(byte[] decrypted) {
+ int pad = decrypted[decrypted.length - 1];
+ if (pad < 1 || pad > 32) {
+ pad = 0;
+ }
+ return Arrays.copyOfRange(decrypted, 0, decrypted.length - pad);
+ }
+
+ /**
+ * 将数字转化成ASCII码对应的字符,用于对明文进行补码
+ *
+ * @param a 需要转化的数字
+ * @return 转化得到的字符
+ */
+ public static char chr(int a) {
+ byte target = (byte) (a & 0xFF);
+ return (char) target;
+ }
+
+}
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java
index df031b3371..9d24d6d3f5 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java
@@ -1,52 +1,37 @@
package me.chanjar.weixin.common.util.fs;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.file.Files;
public class FileUtils {
-
/**
* 创建临时文件
*
- * @param inputStream
+ * @param inputStream 输入文件流
* @param name 文件名
* @param ext 扩展名
* @param tmpDirFile 临时文件夹目录
*/
public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException {
- File tmpFile;
- if (tmpDirFile == null) {
- tmpFile = File.createTempFile(name, '.' + ext);
- } else {
- tmpFile = File.createTempFile(name, '.' + ext, tmpDirFile);
- }
-
- tmpFile.deleteOnExit();
-
- try (FileOutputStream fos = new FileOutputStream(tmpFile)) {
- int read = 0;
- byte[] bytes = new byte[1024 * 100];
- while ((read = inputStream.read(bytes)) != -1) {
- fos.write(bytes, 0, read);
- }
+ File resultFile = File.createTempFile(name, '.' + ext, tmpDirFile);
- fos.flush();
- return tmpFile;
- }
+ resultFile.deleteOnExit();
+ org.apache.commons.io.FileUtils.copyInputStreamToFile(inputStream, resultFile);
+ return resultFile;
}
/**
* 创建临时文件
*
- * @param inputStream
+ * @param inputStream 输入文件流
* @param name 文件名
* @param ext 扩展名
*/
public static File createTmpFile(InputStream inputStream, String name, String ext) throws IOException {
- return createTmpFile(inputStream, name, ext, null);
+ return createTmpFile(inputStream, name, ext, Files.createTempDirectory("weixin-java-tools-temp").toFile());
}
}
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/BaseMediaDownloadRequestExecutor.java
similarity index 85%
rename from weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java
rename to weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/BaseMediaDownloadRequestExecutor.java
index d948859748..990e162008 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/BaseMediaDownloadRequestExecutor.java
@@ -12,11 +12,11 @@
*
* @author Daniel Qian
*/
-public abstract class MediaDownloadRequestExecutor implements RequestExecutor {
-
+public abstract class BaseMediaDownloadRequestExecutor implements RequestExecutor {
protected RequestHttp requestHttp;
protected File tmpDirFile;
- public MediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) {
+
+ public BaseMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) {
this.requestHttp = requestHttp;
this.tmpDirFile = tmpDirFile;
}
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/HttpResponseProxy.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/HttpResponseProxy.java
index a75aa963e0..37efdaaf38 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/HttpResponseProxy.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/HttpResponseProxy.java
@@ -19,6 +19,8 @@
* @author Binary Wang
*/
public class HttpResponseProxy {
+ private static final Pattern PATTERN = Pattern.compile(".*filename=\"(.*)\"");
+
private CloseableHttpResponse apacheHttpResponse;
private HttpResponse joddHttpResponse;
private Response okHttpResponse;
@@ -56,7 +58,7 @@ public String getFileName() throws WxErrorException {
private String getFileName(CloseableHttpResponse response) throws WxErrorException {
Header[] contentDispositionHeader = response.getHeaders("Content-disposition");
if (contentDispositionHeader == null || contentDispositionHeader.length == 0) {
- throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build());
+ throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").build());
}
return this.extractFileNameFromContentString(contentDispositionHeader[0].getValue());
@@ -74,15 +76,15 @@ private String getFileName(Response response) throws WxErrorException {
private String extractFileNameFromContentString(String content) throws WxErrorException {
if (content == null || content.length() == 0) {
- throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build());
+ throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").build());
}
- Pattern p = Pattern.compile(".*filename=\"(.*)\"");
- Matcher m = p.matcher(content);
+ Matcher m = PATTERN.matcher(content);
if (m.matches()) {
return m.group(1);
}
- throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build());
+
+ throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").build());
}
}
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpClientBuilder.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpClientBuilder.java
index 939b624785..fcd56c48a7 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpClientBuilder.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpClientBuilder.java
@@ -4,51 +4,41 @@
import org.apache.http.impl.client.CloseableHttpClient;
/**
- * httpclient build interface
+ * httpclient build interface.
*
* @author kakotor
*/
public interface ApacheHttpClientBuilder {
/**
- * 构建httpclient实例
+ * 构建httpclient实例.
*
* @return new instance of CloseableHttpClient
*/
CloseableHttpClient build();
/**
- * 代理服务器地址
- *
- * @param httpProxyHost
+ * 代理服务器地址.
*/
ApacheHttpClientBuilder httpProxyHost(String httpProxyHost);
/**
- * 代理服务器端口
- *
- * @param httpProxyPort
+ * 代理服务器端口.
*/
ApacheHttpClientBuilder httpProxyPort(int httpProxyPort);
/**
- * 代理服务器用户名
- *
- * @param httpProxyUsername
+ * 代理服务器用户名.
*/
ApacheHttpClientBuilder httpProxyUsername(String httpProxyUsername);
/**
- * 代理服务器密码
- *
- * @param httpProxyPassword
+ * 代理服务器密码.
*/
ApacheHttpClientBuilder httpProxyPassword(String httpProxyPassword);
/**
- * ssl连接socket工厂
- *
- * @param sslConnectionSocketFactory
+ * ssl连接socket工厂.
*/
ApacheHttpClientBuilder sslConnectionSocketFactory(SSLConnectionSocketFactory sslConnectionSocketFactory);
}
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpDnsClientBuilder.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpDnsClientBuilder.java
index d3e5a1c167..b99b09fb8f 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpDnsClientBuilder.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpDnsClientBuilder.java
@@ -29,9 +29,8 @@
import java.util.concurrent.atomic.AtomicBoolean;
/**
- * httpclient 连接管理器 自带DNS解析
- *
- * 大部分代码拷贝自:DefaultApacheHttpClientBuilder
+ * httpclient 连接管理器 自带DNS解析.
+ *
大部分代码拷贝自:DefaultApacheHttpClientBuilder
*
* @author Andy.Huo
*/
@@ -64,7 +63,7 @@ public boolean retryRequest(IOException exception, int executionCount, HttpConte
private String httpProxyPassword;
/**
- * 闲置连接监控线程
+ * 闲置连接监控线程.
*/
private IdleConnectionMonitorThread idleConnectionMonitorThread;
private HttpClientBuilder httpClientBuilder;
@@ -162,7 +161,7 @@ public void setCheckWaitTime(int checkWaitTime) {
}
/**
- * 每路的最大链接数,默认10
+ * 每路的最大链接数,默认10.
*
* @param maxConnPerHost 每路的最大链接数,默认10
*/
@@ -171,7 +170,7 @@ public void setMaxConnPerHost(int maxConnPerHost) {
}
/**
- * 最大总连接数,默认50
+ * 最大总连接数,默认50.
*
* @param maxTotalConn 最大总连接数,默认50
*/
@@ -180,7 +179,7 @@ public void setMaxTotalConn(int maxTotalConn) {
}
/**
- * 自定义httpclient的User Agent
+ * 自定义httpclient的User Agent.
*
* @param userAgent User Agent
*/
@@ -196,9 +195,12 @@ private synchronized void prepare() {
if (prepared.get()) {
return;
}
- Registry registry = RegistryBuilder.create()
- .register("http", this.plainConnectionSocketFactory).register("https", this.sslConnectionSocketFactory)
- .build();
+
+ Registry registry =
+ RegistryBuilder.create()
+ .register("http", this.plainConnectionSocketFactory)
+ .register("https", this.sslConnectionSocketFactory)
+ .build();
@SuppressWarnings("resource")
PoolingHttpClientConnectionManager connectionManager;
@@ -219,8 +221,8 @@ private synchronized void prepare() {
connectionManager
.setDefaultSocketConfig(SocketConfig.copy(SocketConfig.DEFAULT).setSoTimeout(this.soTimeout).build());
- this.idleConnectionMonitorThread = new IdleConnectionMonitorThread(connectionManager, this.idleConnTimeout,
- this.checkWaitTime);
+ this.idleConnectionMonitorThread = new IdleConnectionMonitorThread(
+ connectionManager, this.idleConnTimeout, this.checkWaitTime);
this.idleConnectionMonitorThread.setDaemon(true);
this.idleConnectionMonitorThread.start();
@@ -234,8 +236,8 @@ private synchronized void prepare() {
if (StringUtils.isNotBlank(this.httpProxyHost) && StringUtils.isNotBlank(this.httpProxyUsername)) {
// 使用代理服务器 需要用户认证的代理服务器
CredentialsProvider provider = new BasicCredentialsProvider();
- provider.setCredentials(new AuthScope(this.httpProxyHost, this.httpProxyPort),
- new UsernamePasswordCredentials(this.httpProxyUsername, this.httpProxyPassword));
+ provider.setCredentials(new AuthScope(this.httpProxyHost, this.httpProxyPort)
+ , new UsernamePasswordCredentials(this.httpProxyUsername, this.httpProxyPassword));
this.httpClientBuilder.setDefaultCredentialsProvider(provider);
}
@@ -267,8 +269,10 @@ public static class IdleConnectionMonitorThread extends Thread {
private final int checkWaitTime;
private volatile boolean shutdown;
- public IdleConnectionMonitorThread(HttpClientConnectionManager connMgr, int idleConnTimeout,
- int checkWaitTime) {
+ /**
+ * 构造方法.
+ */
+ public IdleConnectionMonitorThread(HttpClientConnectionManager connMgr, int idleConnTimeout, int checkWaitTime) {
super("IdleConnectionMonitorThread");
this.connMgr = connMgr;
this.idleConnTimeout = idleConnTimeout;
@@ -289,12 +293,18 @@ public void run() {
}
}
+ /**
+ * 触发.
+ */
public void trigger() {
synchronized (this) {
notifyAll();
}
}
+ /**
+ * 关闭.
+ */
public void shutdown() {
this.shutdown = true;
synchronized (this) {
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaDownloadRequestExecutor.java
index 0a5a504873..be2d91b84f 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaDownloadRequestExecutor.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaDownloadRequestExecutor.java
@@ -4,7 +4,7 @@
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.fs.FileUtils;
import me.chanjar.weixin.common.util.http.HttpResponseProxy;
-import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor;
+import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
@@ -23,7 +23,7 @@
/**
* Created by ecoolper on 2017/5/5.
*/
-public class ApacheMediaDownloadRequestExecutor extends MediaDownloadRequestExecutor {
+public class ApacheMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor {
public ApacheMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) {
super(requestHttp, tmpDirFile);
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java
index cc85fa76d7..1a8a292b9f 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java
@@ -39,9 +39,7 @@ public String execute(String uri, String postEntity) throws WxErrorException, IO
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) {
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
if (responseContent.isEmpty()) {
- throw new WxErrorException(
- WxError.newBuilder().setErrorCode(9999).setErrorMsg("无响应内容")
- .build());
+ throw new WxErrorException(WxError.builder().errorCode(9999).errorMsg("无响应内容").build());
}
if (responseContent.startsWith("")) {
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java
index bbd8bec47c..f3442aaa6d 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java
@@ -9,7 +9,7 @@
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.fs.FileUtils;
import me.chanjar.weixin.common.util.http.HttpResponseProxy;
-import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor;
+import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
@@ -22,7 +22,7 @@
/**
* Created by ecoolper on 2017/5/5.
*/
-public class JoddHttpMediaDownloadRequestExecutor extends MediaDownloadRequestExecutor {
+public class JoddHttpMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor {
public JoddHttpMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) {
super(requestHttp, tmpDirFile);
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java
index 8fa349c67a..57207f1b3e 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java
@@ -5,7 +5,6 @@
import jodd.http.HttpResponse;
import jodd.http.ProxyInfo;
import jodd.util.StringPool;
-
import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
@@ -40,9 +39,8 @@ public String execute(String uri, String postEntity) throws WxErrorException, IO
String responseContent = response.bodyText();
if (responseContent.isEmpty()) {
- throw new WxErrorException(
- WxError.newBuilder().setErrorCode(9999).setErrorMsg("无响应内容")
- .build());
+ throw new WxErrorException(WxError.builder().errorCode(9999).errorMsg("无响应内容")
+ .build());
}
if (responseContent.startsWith("")) {
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java
index 0923527b71..80f8199296 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java
@@ -2,8 +2,8 @@
import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
+import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor;
import me.chanjar.weixin.common.util.http.HttpResponseProxy;
-import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import okhttp3.OkHttpClient;
import okhttp3.Request;
@@ -21,7 +21,7 @@
/**
* Created by ecoolper on 2017/5/5.
*/
-public class OkHttpMediaDownloadRequestExecutor extends MediaDownloadRequestExecutor {
+public class OkHttpMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
public OkHttpMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) {
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxErrorAdapter.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxErrorAdapter.java
index cc426bc8ca..abd0da6052 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxErrorAdapter.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxErrorAdapter.java
@@ -14,23 +14,26 @@
import java.lang.reflect.Type;
/**
- * @author Daniel Qian
+ * @author Daniel Qian.
*/
public class WxErrorAdapter implements JsonDeserializer {
@Override
- public WxError deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
- WxError wxError = new WxError();
+ public WxError deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException {
+ WxError.WxErrorBuilder errorBuilder = WxError.builder();
JsonObject wxErrorJsonObject = json.getAsJsonObject();
if (wxErrorJsonObject.get("errcode") != null && !wxErrorJsonObject.get("errcode").isJsonNull()) {
- wxError.setErrorCode(GsonHelper.getAsPrimitiveInt(wxErrorJsonObject.get("errcode")));
+ errorBuilder.errorCode(GsonHelper.getAsPrimitiveInt(wxErrorJsonObject.get("errcode")));
}
if (wxErrorJsonObject.get("errmsg") != null && !wxErrorJsonObject.get("errmsg").isJsonNull()) {
- wxError.setErrorMsg(GsonHelper.getAsString(wxErrorJsonObject.get("errmsg")));
+ errorBuilder.errorMsg(GsonHelper.getAsString(wxErrorJsonObject.get("errmsg")));
}
- wxError.setJson(json.toString());
- return wxError;
+
+ errorBuilder.json(json.toString());
+
+ return errorBuilder.build();
}
}
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxMenuGsonAdapter.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxMenuGsonAdapter.java
index c506c1ed75..31c3c0204c 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxMenuGsonAdapter.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxMenuGsonAdapter.java
@@ -70,6 +70,7 @@ protected JsonObject convertToJson(WxMenuRule menuRule) {
return matchRule;
}
+ @Deprecated
private WxMenuRule convertToRule(JsonObject json) {
WxMenuRule menuRule = new WxMenuRule();
//变态的微信接口,这里居然反人类的使用和序列化时不一样的名字
diff --git a/weixin-java-common/src/test/java/me/chanjar/weixin/common/bean/WxErrorTest.java b/weixin-java-common/src/test/java/me/chanjar/weixin/common/bean/WxErrorTest.java
index 477fcdabc0..1c05ea731e 100644
--- a/weixin-java-common/src/test/java/me/chanjar/weixin/common/bean/WxErrorTest.java
+++ b/weixin-java-common/src/test/java/me/chanjar/weixin/common/bean/WxErrorTest.java
@@ -8,7 +8,6 @@
public class WxErrorTest {
public void testFromJson() {
-
String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\" }";
WxError wxError = WxError.fromJson(json);
Assert.assertTrue(wxError.getErrorCode() == 40003);
diff --git a/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/crypto/SHA1Test.java b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/crypto/SHA1Test.java
index 323fc7060e..ffdb613128 100644
--- a/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/crypto/SHA1Test.java
+++ b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/crypto/SHA1Test.java
@@ -10,7 +10,7 @@
* Created by BinaryWang on 2017/6/10.
*
*
- * @author binarywang(Binary Wang)
+ * @author Binary Wang
*/
public class SHA1Test {
@Test
diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml
index 233a94ecc3..f589bbe003 100644
--- a/weixin-java-cp/pom.xml
+++ b/weixin-java-cp/pom.xml
@@ -7,7 +7,7 @@
* 默认接口实现类,使用apache httpclient实现 * Created by Binary Wang on 2017-5-27. - * @author binarywang(Binary Wang) *+ * + * @author Binary Wang */ public class WxCpServiceImpl extends WxCpServiceApacheHttpClientImpl { } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java index f8476ff5af..af9219cfe8 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java @@ -7,14 +7,10 @@ import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import okhttp3.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.IOException; public class WxCpServiceOkHttpImpl extends WxCpServiceAbstractImpl
* 请使用
- * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_TEXT}
- * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_IMAGE}
- * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VOICE}
- * {@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_NEWS}
- * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MPNEWS}
+ * {@link WxConsts.KefuMsgType#TEXT}
+ * {@link WxConsts.KefuMsgType#IMAGE}
+ * {@link WxConsts.KefuMsgType#VOICE}
+ * {@link WxConsts.KefuMsgType#MUSIC}
+ * {@link WxConsts.KefuMsgType#VIDEO}
+ * {@link WxConsts.KefuMsgType#NEWS}
+ * {@link WxConsts.KefuMsgType#MPNEWS}
*
*
* @param msgType 消息类型
@@ -152,87 +112,8 @@ public void setMsgType(String msgType) {
this.msgType = msgType;
}
- public String getSafe() {
- return this.safe;
- }
-
- public void setSafe(String safe) {
- this.safe = safe;
- }
-
- public String getContent() {
- return this.content;
- }
-
- public void setContent(String content) {
- this.content = content;
- }
-
- public String getMediaId() {
- return this.mediaId;
- }
-
- public void setMediaId(String mediaId) {
- this.mediaId = mediaId;
- }
-
- public String getThumbMediaId() {
- return this.thumbMediaId;
- }
-
- public void setThumbMediaId(String thumbMediaId) {
- this.thumbMediaId = thumbMediaId;
- }
-
- public String getTitle() {
- return this.title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getMusicUrl() {
- return this.musicUrl;
- }
-
- public void setMusicUrl(String musicUrl) {
- this.musicUrl = musicUrl;
- }
-
- public String getHqMusicUrl() {
- return this.hqMusicUrl;
- }
-
- public void setHqMusicUrl(String hqMusicUrl) {
- this.hqMusicUrl = hqMusicUrl;
- }
-
- public List- * 消息发送结果对象类 + * 消息发送结果对象类. * Created by Binary Wang on 2017-6-22. + * * @author Binary Wang - **/ -public class WxCpMessageSendResult { +@Data +public class WxCpMessageSendResult implements Serializable { + private static final long serialVersionUID = 916455987193190004L; + @Override public String toString() { return ToStringUtils.toSimpleString(this); @@ -41,52 +45,13 @@ public static WxCpMessageSendResult fromJson(String json) { @SerializedName("invalidtag") private String invalidTag; - public Integer getErrCode() { - return this.errCode; - } - - public void setErrCode(Integer errCode) { - this.errCode = errCode; - } - - public String getErrMsg() { - return this.errMsg; - } - - public void setErrMsg(String errMsg) { - this.errMsg = errMsg; - } - - public String getInvalidUser() { - return this.invalidUser; - } - - public void setInvalidUser(String invalidUser) { - this.invalidUser = invalidUser; - } - - public String getInvalidParty() { - return this.invalidParty; - } - - public void setInvalidParty(String invalidParty) { - this.invalidParty = invalidParty; - } - - public String getInvalidTag() { - return this.invalidTag; - } - - public void setInvalidTag(String invalidTag) { - this.invalidTag = invalidTag; - } public List
- * 为标签添加或移除用户结果对象类 + * 为标签添加或移除用户结果对象类. * Created by Binary Wang on 2017-6-22. + * * @author Binary Wang - **/ -public class WxCpTagAddOrRemoveUsersResult { +@Data +public class WxCpTagAddOrRemoveUsersResult implements Serializable { + private static final long serialVersionUID = 1420065684270213578L; + @Override public String toString() { return ToStringUtils.toSimpleString(this); @@ -38,44 +42,12 @@ public static WxCpTagAddOrRemoveUsersResult fromJson(String json) { @SerializedName("invalidparty") private String[] invalidParty; - public Integer getErrCode() { - return this.errCode; - } - - public void setErrCode(Integer errCode) { - this.errCode = errCode; - } - - public String getErrMsg() { - return this.errMsg; - } - - public void setErrMsg(String errMsg) { - this.errMsg = errMsg; - } - - public String getInvalidUser() { - return this.invalidUsers; - } - - public void setInvalidUser(String invalidUser) { - this.invalidUsers = invalidUser; - } - - public String[] getInvalidParty() { - return this.invalidParty; - } - - public void setInvalidParty(String[] invalidParty) { - this.invalidParty = invalidParty; - } - public List
* 当接受用户消息时,可能会获得以下值:
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LOCATION}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LINK}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_EVENT}
+ * {@link WxConsts.XmlMsgType#TEXT}
+ * {@link WxConsts.XmlMsgType#IMAGE}
+ * {@link WxConsts.XmlMsgType#VOICE}
+ * {@link WxConsts.XmlMsgType#VIDEO}
+ * {@link WxConsts.XmlMsgType#LOCATION}
+ * {@link WxConsts.XmlMsgType#LINK}
+ * {@link WxConsts.XmlMsgType#EVENT}
*
*/
public String getMsgType() {
@@ -245,363 +220,60 @@ public String getMsgType() {
/**
*
* 当发送消息的时候使用:
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_NEWS}
+ * {@link WxConsts.XmlMsgType#TEXT}
+ * {@link WxConsts.XmlMsgType#IMAGE}
+ * {@link WxConsts.XmlMsgType#VOICE}
+ * {@link WxConsts.XmlMsgType#VIDEO}
+ * {@link WxConsts.XmlMsgType#NEWS}
*
- *
- * @param msgType
*/
public void setMsgType(String msgType) {
this.msgType = msgType;
}
- public String getContent() {
- return this.content;
- }
-
- public void setContent(String content) {
- this.content = content;
- }
-
- public Long getMsgId() {
- return this.msgId;
- }
-
- public void setMsgId(Long msgId) {
- this.msgId = msgId;
- }
-
- public String getPicUrl() {
- return this.picUrl;
- }
-
- public void setPicUrl(String picUrl) {
- this.picUrl = picUrl;
- }
-
- public String getMediaId() {
- return this.mediaId;
- }
-
- public void setMediaId(String mediaId) {
- this.mediaId = mediaId;
- }
-
- public String getFormat() {
- return this.format;
- }
-
- public void setFormat(String format) {
- this.format = format;
- }
-
- public String getThumbMediaId() {
- return this.thumbMediaId;
- }
-
- public void setThumbMediaId(String thumbMediaId) {
- this.thumbMediaId = thumbMediaId;
- }
-
- public Double getLocationX() {
- return this.locationX;
- }
-
- public void setLocationX(Double locationX) {
- this.locationX = locationX;
- }
-
- public Double getLocationY() {
- return this.locationY;
- }
-
- public void setLocationY(Double locationY) {
- this.locationY = locationY;
- }
-
- public Double getScale() {
- return this.scale;
- }
-
- public void setScale(Double scale) {
- this.scale = scale;
- }
-
- public String getLabel() {
- return this.label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- public String getTitle() {
- return this.title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getUrl() {
- return this.url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public String getEvent() {
- return this.event;
- }
-
- public void setEvent(String event) {
- this.event = event;
- }
-
- public String getEventKey() {
- return this.eventKey;
- }
-
- public void setEventKey(String eventKey) {
- this.eventKey = eventKey;
- }
-
- public String getTicket() {
- return this.ticket;
- }
-
- public void setTicket(String ticket) {
- this.ticket = ticket;
- }
-
- public Double getLatitude() {
- return this.latitude;
- }
-
- public void setLatitude(Double latitude) {
- this.latitude = latitude;
- }
-
- public Double getLongitude() {
- return this.longitude;
- }
-
- public void setLongitude(Double longitude) {
- this.longitude = longitude;
- }
-
- public Double getPrecision() {
- return this.precision;
- }
-
- public void setPrecision(Double precision) {
- this.precision = precision;
- }
-
- public String getRecognition() {
- return this.recognition;
- }
-
- public void setRecognition(String recognition) {
- this.recognition = recognition;
- }
-
- public String getFromUserName() {
- return this.fromUserName;
- }
-
- public void setFromUserName(String fromUserName) {
- this.fromUserName = fromUserName;
- }
-
- public String getStatus() {
- return this.status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public Integer getTotalCount() {
- return this.totalCount;
- }
-
- public void setTotalCount(Integer totalCount) {
- this.totalCount = totalCount;
- }
-
- public Integer getFilterCount() {
- return this.filterCount;
- }
-
- public void setFilterCount(Integer filterCount) {
- this.filterCount = filterCount;
- }
-
- public Integer getSentCount() {
- return this.sentCount;
- }
-
- public void setSentCount(Integer sentCount) {
- this.sentCount = sentCount;
- }
-
- public Integer getErrorCount() {
- return this.errorCount;
- }
-
- public void setErrorCount(Integer errorCount) {
- this.errorCount = errorCount;
- }
-
- public WxCpXmlMessage.ScanCodeInfo getScanCodeInfo() {
- return this.scanCodeInfo;
- }
-
- public void setScanCodeInfo(WxCpXmlMessage.ScanCodeInfo scanCodeInfo) {
- this.scanCodeInfo = scanCodeInfo;
- }
-
- public WxCpXmlMessage.SendPicsInfo getSendPicsInfo() {
- return this.sendPicsInfo;
- }
-
- public void setSendPicsInfo(WxCpXmlMessage.SendPicsInfo sendPicsInfo) {
- this.sendPicsInfo = sendPicsInfo;
- }
-
- public WxCpXmlMessage.SendLocationInfo getSendLocationInfo() {
- return this.sendLocationInfo;
- }
-
- public void setSendLocationInfo(WxCpXmlMessage.SendLocationInfo sendLocationInfo) {
- this.sendLocationInfo = sendLocationInfo;
- }
-
@Override
public String toString() {
- return "WxCpXmlMessage{" +
- "agentId=" + this.agentId +
- ", toUserName='" + this.toUserName + '\'' +
- ", fromUserName='" + this.fromUserName + '\'' +
- ", createTime=" + this.createTime +
- ", msgType='" + this.msgType + '\'' +
- ", content='" + this.content + '\'' +
- ", msgId=" + this.msgId +
- ", picUrl='" + this.picUrl + '\'' +
- ", mediaId='" + this.mediaId + '\'' +
- ", format='" + this.format + '\'' +
- ", thumbMediaId='" + this.thumbMediaId + '\'' +
- ", locationX=" + this.locationX +
- ", locationY=" + this.locationY +
- ", scale=" + this.scale +
- ", label='" + this.label + '\'' +
- ", title='" + this.title + '\'' +
- ", description='" + this.description + '\'' +
- ", url='" + this.url + '\'' +
- ", event='" + this.event + '\'' +
- ", eventKey='" + this.eventKey + '\'' +
- ", ticket='" + this.ticket + '\'' +
- ", latitude=" + this.latitude +
- ", longitude=" + this.longitude +
- ", precision=" + this.precision +
- ", recognition='" + this.recognition + '\'' +
- ", status='" + this.status + '\'' +
- ", totalCount=" + this.totalCount +
- ", filterCount=" + this.filterCount +
- ", sentCount=" + this.sentCount +
- ", errorCount=" + this.errorCount +
- ", scanCodeInfo=" + this.scanCodeInfo +
- ", sendPicsInfo=" + this.sendPicsInfo +
- ", sendLocationInfo=" + this.sendLocationInfo +
- '}';
+ return ToStringUtils.toSimpleString(this);
}
+ @Data
@XStreamAlias("ScanCodeInfo")
public static class ScanCodeInfo {
+ /**
+ * 扫描类型,一般是qrcode.
+ */
@XStreamAlias("ScanType")
@XStreamConverter(value = XStreamCDataConverter.class)
private String scanType;
+ /**
+ * 扫描结果,即二维码对应的字符串信息.
+ */
@XStreamAlias("ScanResult")
@XStreamConverter(value = XStreamCDataConverter.class)
private String scanResult;
-
- /**
- * 扫描类型,一般是qrcode
- */
- public String getScanType() {
-
- return this.scanType;
- }
-
- public void setScanType(String scanType) {
- this.scanType = scanType;
- }
-
- /**
- * 扫描结果,即二维码对应的字符串信息
- */
- public String getScanResult() {
- return this.scanResult;
- }
-
- public void setScanResult(String scanResult) {
- this.scanResult = scanResult;
- }
-
}
+ @Data
@XStreamAlias("SendPicsInfo")
public static class SendPicsInfo {
-
@XStreamAlias("PicList")
protected final List+ * 使用说明:本实现仅供参考,并不完整, + * 比如为减少项目依赖,未加入redis分布式锁的实现,如有需要请自行实现。 + ** * @author gaigeshen */ diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouter.java index 3c53d26106..99e4fd4573 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouter.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouter.java @@ -11,6 +11,7 @@ import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpXmlMessage; import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -215,17 +216,19 @@ public WxCpXmlOutMessage route(final WxCpXmlMessage wxMessage) { } protected boolean isDuplicateMessage(WxCpXmlMessage wxMessage) { - - String messageId = ""; + String messageId; if (wxMessage.getMsgId() == null) { messageId = String.valueOf(wxMessage.getCreateTime()) - + "-" + String.valueOf(wxMessage.getAgentId() == null ? "" : wxMessage.getAgentId()) + + "-" + StringUtils.trimToEmpty(String.valueOf(wxMessage.getAgentId())) + "-" + wxMessage.getFromUserName() - + "-" + String.valueOf(wxMessage.getEventKey() == null ? "" : wxMessage.getEventKey()) - + "-" + String.valueOf(wxMessage.getEvent() == null ? "" : wxMessage.getEvent()) + + "-" + StringUtils.trimToEmpty(wxMessage.getEventKey()) + + "-" + StringUtils.trimToEmpty(wxMessage.getEvent()) ; } else { - messageId = String.valueOf(wxMessage.getMsgId()); + messageId = new StringBuilder().append(wxMessage.getMsgId()) + .append("-").append(wxMessage.getCreateTime()) + .append("-").append(wxMessage.getFromUserName()) + .toString(); } return this.messageDuplicateChecker.isDuplicate(messageId); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpDepartGsonAdapter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpDepartGsonAdapter.java index 431c38039b..a5a11d24f4 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpDepartGsonAdapter.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpDepartGsonAdapter.java @@ -49,7 +49,7 @@ public WxCpDepart deserialize(JsonElement json, Type typeOfT, JsonDeserializatio depart.setName(GsonHelper.getAsString(departJson.get("name"))); } if (departJson.get("order") != null && !departJson.get("order").isJsonNull()) { - depart.setOrder(GsonHelper.getAsInteger(departJson.get("order"))); + depart.setOrder(GsonHelper.getAsLong(departJson.get("order"))); } if (departJson.get("parentid") != null && !departJson.get("parentid").isJsonNull()) { depart.setParentId(GsonHelper.getAsInteger(departJson.get("parentid"))); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMessageGsonAdapter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMessageGsonAdapter.java index 67e43c4ccc..5e19b50121 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMessageGsonAdapter.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMessageGsonAdapter.java @@ -37,13 +37,13 @@ public JsonElement serialize(WxCpMessage message, Type typeOfSrc, JsonSerializat if (StringUtils.isNotBlank(message.getToTag())) { messageJson.addProperty("totag", message.getToTag()); } - if (WxConsts.CUSTOM_MSG_TEXT.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.TEXT.equals(message.getMsgType())) { JsonObject text = new JsonObject(); text.addProperty("content", message.getContent()); messageJson.add("text", text); } - if (WxConsts.CUSTOM_MSG_TEXTCARD.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.TEXTCARD.equals(message.getMsgType())) { JsonObject text = new JsonObject(); text.addProperty("title", message.getTitle()); text.addProperty("description", message.getDescription()); @@ -51,19 +51,19 @@ public JsonElement serialize(WxCpMessage message, Type typeOfSrc, JsonSerializat messageJson.add("textcard", text); } - if (WxConsts.CUSTOM_MSG_IMAGE.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.IMAGE.equals(message.getMsgType())) { JsonObject image = new JsonObject(); image.addProperty("media_id", message.getMediaId()); messageJson.add("image", image); } - if (WxConsts.CUSTOM_MSG_FILE.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.FILE.equals(message.getMsgType())) { JsonObject image = new JsonObject(); image.addProperty("media_id", message.getMediaId()); messageJson.add("file", image); } - if (WxConsts.CUSTOM_MSG_VOICE.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.VOICE.equals(message.getMsgType())) { JsonObject voice = new JsonObject(); voice.addProperty("media_id", message.getMediaId()); messageJson.add("voice", voice); @@ -73,7 +73,7 @@ public JsonElement serialize(WxCpMessage message, Type typeOfSrc, JsonSerializat messageJson.addProperty("safe", message.getSafe()); } - if (WxConsts.CUSTOM_MSG_VIDEO.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.VIDEO.equals(message.getMsgType())) { JsonObject video = new JsonObject(); video.addProperty("media_id", message.getMediaId()); video.addProperty("thumb_media_id", message.getThumbMediaId()); @@ -82,7 +82,7 @@ public JsonElement serialize(WxCpMessage message, Type typeOfSrc, JsonSerializat messageJson.add("video", video); } - if (WxConsts.CUSTOM_MSG_NEWS.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.NEWS.equals(message.getMsgType())) { JsonObject newsJsonObject = new JsonObject(); JsonArray articleJsonArray = new JsonArray(); for (NewArticle article : message.getArticles()) { @@ -97,7 +97,7 @@ public JsonElement serialize(WxCpMessage message, Type typeOfSrc, JsonSerializat messageJson.add("news", newsJsonObject); } - if (WxConsts.CUSTOM_MSG_MPNEWS.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.MPNEWS.equals(message.getMsgType())) { JsonObject newsJsonObject = new JsonObject(); if (message.getMediaId() != null) { newsJsonObject.addProperty("media_id", message.getMediaId()); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/xml/XStreamTransformer.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/xml/XStreamTransformer.java index 6b58063062..e08ef4df60 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/xml/XStreamTransformer.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/xml/XStreamTransformer.java @@ -28,7 +28,7 @@ public static
+ * lineColor 包装类 + * 用于描述二维码(小程序码)颜色(RGB参数值), + * 详情请查看文档 https://mp.weixin.qq.com/debug/wxadoc/dev/api/qrcode.html + *+ * @author Element + */ +@Data +@AllArgsConstructor +public class WxMaCodeLineColor { + private String r = "0", g = "0", b = "0"; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java index 471e6c46ec..7d3e2d8de6 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java @@ -2,13 +2,21 @@ import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; /** * {"session_key":"nzoqhc3OnwHzeTxJs+inbQ==","expires_in":2592000,"openid":"oVBkZ0aYgDMDIywRdgPW8-joxXc4"} * * @author Binary Wang */ -public class WxMaJscode2SessionResult { +@Data +@EqualsAndHashCode(callSuper = false) +public class WxMaJscode2SessionResult implements Serializable { + private static final long serialVersionUID = -1060216618475607933L; + @SerializedName("session_key") private String sessionKey; @@ -25,36 +33,4 @@ public static WxMaJscode2SessionResult fromJson(String json) { return WxMaGsonBuilder.create().fromJson(json, WxMaJscode2SessionResult.class); } - public String getSessionKey() { - return sessionKey; - } - - public void setSessionKey(String sessionKey) { - this.sessionKey = sessionKey; - } - - public Integer getExpiresin() { - return expiresin; - } - - public void setExpiresin(Integer expiresin) { - this.expiresin = expiresin; - } - - public String getOpenid() { - return openid; - } - - public void setOpenid(String openid) { - this.openid = openid; - } - - public String getUnionid() { - return unionid; - } - - public void setUnionid(String unionid) { - this.unionid = unionid; - } - } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessage.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessage.java index d75fbf12ae..ec1728db60 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessage.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessage.java @@ -3,6 +3,7 @@ import cn.binarywang.wx.miniapp.builder.ImageBuilder; import cn.binarywang.wx.miniapp.builder.TextBuilder; import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; +import lombok.Data; import java.io.Serializable; @@ -11,6 +12,7 @@ * * @author Binary Wang */ +@Data public class WxMaKefuMessage implements Serializable { private static final long serialVersionUID = -9196732086954365246L; @@ -25,73 +27,17 @@ public class WxMaKefuMessage implements Serializable { /** * 获得文本消息builder */ - public static TextBuilder TEXT() { + public static TextBuilder newTextBuilder() { return new TextBuilder(); } /** * 获得图片消息builder */ - public static ImageBuilder IMAGE() { + public static ImageBuilder newImageBuilder() { return new ImageBuilder(); } - public String getToUser() { - return this.toUser; - } - - public void setToUser(String toUser) { - this.toUser = toUser; - } - - public String getMsgType() { - return this.msgType; - } - - public void setMsgType(String msgType) { - this.msgType = msgType; - } - - public String getContent() { - return this.content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - - public String getThumbMediaId() { - return this.thumbMediaId; - } - - public void setThumbMediaId(String thumbMediaId) { - this.thumbMediaId = thumbMediaId; - } - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - public String toJson() { return WxMaGsonBuilder.create().toJson(this); } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java index 4b201da1cd..cb1fed6923 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java @@ -7,6 +7,7 @@ import com.google.gson.annotations.SerializedName; import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import org.apache.commons.io.IOUtils; @@ -20,6 +21,7 @@ * @author Binary Wang */ @XStreamAlias("xml") +@Data public class WxMaMessage implements Serializable { private static final long serialVersionUID = -3586245291677274914L; @@ -146,91 +148,4 @@ public String toJson() { return WxMaGsonBuilder.create().toJson(this); } - public String getToUser() { - return toUser; - } - - public void setToUser(String toUser) { - this.toUser = toUser; - } - - public String getFromUser() { - return fromUser; - } - - public void setFromUser(String fromUser) { - this.fromUser = fromUser; - } - - public Integer getCreateTime() { - return createTime; - } - - public void setCreateTime(Integer createTime) { - this.createTime = createTime; - } - - public String getMsgType() { - return msgType; - } - - public void setMsgType(String msgType) { - this.msgType = msgType; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public Long getMsgId() { - return msgId; - } - - public void setMsgId(Long msgId) { - this.msgId = msgId; - } - - public String getPicUrl() { - return picUrl; - } - - public void setPicUrl(String picUrl) { - this.picUrl = picUrl; - } - - public String getMediaId() { - return mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - - public String getEvent() { - return event; - } - - public void setEvent(String event) { - this.event = event; - } - - public String getSessionFrom() { - return sessionFrom; - } - - public void setSessionFrom(String sessionFrom) { - this.sessionFrom = sessionFrom; - } - - public String getEncrypt() { - return encrypt; - } - - public void setEncrypt(String encrypt) { - this.encrypt = encrypt; - } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcode.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcode.java index a047d7c8b1..5c17cd1e58 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcode.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcode.java @@ -1,13 +1,17 @@ package cn.binarywang.wx.miniapp.bean; import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; +import lombok.Data; +import lombok.EqualsAndHashCode; import java.io.Serializable; /** * @author Binary Wang */ -public class WxMaQrcode extends WxMaQrcodeWrapper implements Serializable { +@Data +@EqualsAndHashCode(callSuper = false) +public class WxMaQrcode extends AbstractWxMaQrcodeWrapper implements Serializable { private static final long serialVersionUID = 5777119669111011584L; private String path; private int width = 430; @@ -21,22 +25,6 @@ public static WxMaQrcode fromJson(String json) { return WxMaGsonBuilder.create().fromJson(json, WxMaQrcode.class); } - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - @Override public String toString() { return WxMaGsonBuilder.create().toJson(this); diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessage.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessage.java index 79f955c6d2..32268b4c4b 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessage.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessage.java @@ -1,6 +1,8 @@ package cn.binarywang.wx.miniapp.bean; import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; +import lombok.Builder; +import lombok.Data; import java.io.Serializable; import java.util.ArrayList; @@ -11,6 +13,8 @@ * * @author Binary Wang */ +@Data +@Builder public class WxMaTemplateMessage implements Serializable { private static final long serialVersionUID = 5063374783759519418L; @@ -57,7 +61,8 @@ public class WxMaTemplateMessage implements Serializable { * 描述: 模板内容,不填则下发空模板 * */ - private List data = new ArrayList<>(); + @Builder.Default + private final List data = new ArrayList<>(); /** *
@@ -77,80 +82,11 @@ public class WxMaTemplateMessage implements Serializable {
*/
private String emphasisKeyword;
- private WxMaTemplateMessage(Builder builder) {
- setToUser(builder.toUser);
- setTemplateId(builder.templateId);
- setPage(builder.page);
- setFormId(builder.formId);
- setData(builder.data);
- setColor(builder.color);
- setEmphasisKeyword(builder.emphasisKeyword);
- }
-
- public static Builder newBuilder() {
- return new Builder();
- }
-
public String toJson() {
return WxMaGsonBuilder.create().toJson(this);
}
- public String getToUser() {
- return toUser;
- }
-
- public void setToUser(String toUser) {
- this.toUser = toUser;
- }
-
- public String getTemplateId() {
- return templateId;
- }
-
- public void setTemplateId(String templateId) {
- this.templateId = templateId;
- }
-
- public String getPage() {
- return page;
- }
-
- public void setPage(String page) {
- this.page = page;
- }
-
- public String getFormId() {
- return formId;
- }
-
- public void setFormId(String formId) {
- this.formId = formId;
- }
-
- public List getData() {
- return data;
- }
-
- public void setData(List data) {
- this.data = data;
- }
-
- public String getColor() {
- return color;
- }
-
- public void setColor(String color) {
- this.color = color;
- }
-
- public String getEmphasisKeyword() {
- return emphasisKeyword;
- }
-
- public void setEmphasisKeyword(String emphasisKeyword) {
- this.emphasisKeyword = emphasisKeyword;
- }
-
+ @lombok.Data
public static class Data {
private String name;
private String value;
@@ -167,81 +103,6 @@ public Data(String name, String value, String color) {
this.color = color;
}
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return this.value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String getColor() {
- return this.color;
- }
-
- public void setColor(String color) {
- this.color = color;
- }
-
}
- public static final class Builder {
- private String toUser;
- private String templateId;
- private String page;
- private String formId;
- private List data;
- private String color;
- private String emphasisKeyword;
-
- private Builder() {
- }
-
- public Builder toUser(String toUser) {
- this.toUser = toUser;
- return this;
- }
-
- public Builder templateId(String templateId) {
- this.templateId = templateId;
- return this;
- }
-
- public Builder page(String page) {
- this.page = page;
- return this;
- }
-
- public Builder formId(String formId) {
- this.formId = formId;
- return this;
- }
-
- public Builder data(List data) {
- this.data = data;
- return this;
- }
-
- public Builder color(String color) {
- this.color = color;
- return this;
- }
-
- public Builder emphasisKeyword(String emphasisKeyword) {
- this.emphasisKeyword = emphasisKeyword;
- return this;
- }
-
- public WxMaTemplateMessage build() {
- return new WxMaTemplateMessage(this);
- }
- }
}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java
index e3cc69d913..8b0ed8fe6a 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java
@@ -1,13 +1,17 @@
package cn.binarywang.wx.miniapp.bean;
import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
+import lombok.Data;
+
+import java.io.Serializable;
/**
* @author Binary Wang
*/
-public class WxMaUserInfo {
+@Data
+public class WxMaUserInfo implements Serializable {
+ private static final long serialVersionUID = 6719822331555402137L;
+
private String openId;
private String nickName;
private String gender;
@@ -23,109 +27,9 @@ public static WxMaUserInfo fromJson(String json) {
return WxMaGsonBuilder.create().fromJson(json, WxMaUserInfo.class);
}
- @Override
- public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
- }
-
- public String getOpenId() {
- return openId;
- }
-
- public void setOpenId(String openId) {
- this.openId = openId;
- }
-
- public String getNickName() {
- return nickName;
- }
-
- public void setNickName(String nickName) {
- this.nickName = nickName;
- }
-
- public String getGender() {
- return gender;
- }
-
- public void setGender(String gender) {
- this.gender = gender;
- }
-
- public String getLanguage() {
- return language;
- }
-
- public void setLanguage(String language) {
- this.language = language;
- }
-
- public String getCity() {
- return city;
- }
-
- public void setCity(String city) {
- this.city = city;
- }
-
- public String getProvince() {
- return province;
- }
-
- public void setProvince(String province) {
- this.province = province;
- }
-
- public String getCountry() {
- return country;
- }
-
- public void setCountry(String country) {
- this.country = country;
- }
-
- public String getAvatarUrl() {
- return avatarUrl;
- }
-
- public void setAvatarUrl(String avatarUrl) {
- this.avatarUrl = avatarUrl;
- }
-
- public String getUnionId() {
- return unionId;
- }
-
- public void setUnionId(String unionId) {
- this.unionId = unionId;
- }
-
- public Watermark getWatermark() {
- return watermark;
- }
-
- public void setWatermark(Watermark watermark) {
- this.watermark = watermark;
- }
-
+ @Data
public static class Watermark {
private String timestamp;
private String appid;
-
- public String getTimestamp() {
- return timestamp;
- }
-
- public void setTimestamp(String timestamp) {
- this.timestamp = timestamp;
- }
-
- public String getAppid() {
- return appid;
- }
-
- public void setAppid(String appid) {
- this.appid = appid;
- }
}
}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java
index 9ea674ed98..8e629096c6 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java
@@ -1,17 +1,22 @@
package cn.binarywang.wx.miniapp.bean;
-import cn.binarywang.wx.miniapp.api.WxMaQrcodeService;
import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder;
import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
- * Created by Element on 2017/7/27.
+ *
+ * @author Element
+ * @date 2017/7/27
*/
-public class WxMaWxcode extends WxMaQrcodeWrapper implements Serializable {
-
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class WxMaWxcode extends AbstractWxMaQrcodeWrapper implements Serializable {
private static final long serialVersionUID = 1287399621649210322L;
+
private String path;
private int width = 430;
@@ -19,46 +24,10 @@ public class WxMaWxcode extends WxMaQrcodeWrapper implements Serializable {
private boolean autoColor = true;
@SerializedName("line_color")
- private WxMaQrcodeService.LineColor lineColor = new WxMaQrcodeService.LineColor("0", "0", "0");
+ private WxMaCodeLineColor lineColor = new WxMaCodeLineColor("0", "0", "0");
public static WxMaWxcode fromJson(String json) {
return WxMaGsonBuilder.create().fromJson(json, WxMaWxcode.class);
}
- public static long getSerialVersionUID() {
- return serialVersionUID;
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public int getWidth() {
- return width;
- }
-
- public void setWidth(int width) {
- this.width = width;
- }
-
- public boolean isAutoColor() {
- return autoColor;
- }
-
- public void setAutoColor(boolean autoColor) {
- this.autoColor = autoColor;
- }
-
- public WxMaQrcodeService.LineColor getLineColor() {
- return lineColor;
- }
-
- public void setLineColor(WxMaQrcodeService.LineColor lineColor) {
- this.lineColor = lineColor;
- }
-
}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java
index 7619fe46f2..5f76273b54 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java
@@ -1,15 +1,20 @@
package cn.binarywang.wx.miniapp.bean;
-import cn.binarywang.wx.miniapp.api.WxMaQrcodeService;
import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder;
import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
- * Created by Element on 2017/7/27.
+ *
+ * @author Element
+ * @date 2017/7/27
*/
-public class WxMaWxcodeLimit extends WxMaQrcodeWrapper implements Serializable {
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class WxMaWxcodeLimit extends AbstractWxMaQrcodeWrapper implements Serializable {
private static final long serialVersionUID = 4782193774524960401L;
private String scene;
private String page;
@@ -20,49 +25,10 @@ public class WxMaWxcodeLimit extends WxMaQrcodeWrapper implements Serializable {
private boolean autoColor = true;
@SerializedName("line_color")
- private WxMaQrcodeService.LineColor lineColor = new WxMaQrcodeService.LineColor("0", "0", "0");
+ private WxMaCodeLineColor lineColor = new WxMaCodeLineColor("0", "0", "0");
public static WxMaWxcodeLimit fromJson(String json) {
return WxMaGsonBuilder.create().fromJson(json, WxMaWxcodeLimit.class);
}
- public String getPage() {
- return page;
- }
-
- public void setPage(String page) {
- this.page = page;
- }
-
- public String getScene() {
- return scene;
- }
-
- public void setScene(String scene) {
- this.scene = scene;
- }
-
- public int getWidth() {
- return width;
- }
-
- public void setWidth(int width) {
- this.width = width;
- }
-
- public boolean isAutoColor() {
- return autoColor;
- }
-
- public void setAutoColor(boolean autoColor) {
- this.autoColor = autoColor;
- }
-
- public WxMaQrcodeService.LineColor getLineColor() {
- return lineColor;
- }
-
- public void setLineColor(WxMaQrcodeService.LineColor lineColor) {
- this.lineColor = lineColor;
- }
}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/BaseBuilder.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/BaseBuilder.java
index 70d7cf4b7c..c353534c3f 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/BaseBuilder.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/BaseBuilder.java
@@ -15,6 +15,9 @@ public T toUser(String toUser) {
return (T) this;
}
+ /**
+ * 构造器方法.
+ */
public WxMaKefuMessage build() {
WxMaKefuMessage m = new WxMaKefuMessage();
m.setMsgType(this.msgType);
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/ImageBuilder.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/ImageBuilder.java
index a903e97c43..d4bd068877 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/ImageBuilder.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/ImageBuilder.java
@@ -13,8 +13,8 @@ public ImageBuilder() {
this.msgType = WxMaConstants.KefuMsgType.IMAGE;
}
- public ImageBuilder mediaId(String media_id) {
- this.mediaId = media_id;
+ public ImageBuilder mediaId(String mediaId) {
+ this.mediaId = mediaId;
return this;
}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/WxMaInMemoryConfig.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/WxMaInMemoryConfig.java
index 735a52b56a..7d84c90fbf 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/WxMaInMemoryConfig.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/WxMaInMemoryConfig.java
@@ -175,6 +175,7 @@ public boolean autoRefreshToken() {
return true;
}
+ @Override
public String getAppid() {
return appid;
}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java
index 14016fa578..ccc492d1e0 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java
@@ -8,11 +8,19 @@
* @author Binary Wang
*/
public class WxMaConstants {
+ /**
+ * 微信接口返回的参数errcode
+ */
+ public static final String ERRCODE = "errcode";
+
/**
* 素材类型
*/
public static class MediaType {
- public static final String IMAGE = "image";//图片
+ /**
+ * 图片
+ */
+ public static final String IMAGE = "image";
}
/**
@@ -27,7 +35,30 @@ public static class MsgDataFormat {
* 客服消息的消息类型
*/
public static class KefuMsgType {
- public static final String TEXT = "text";//文本消息
- public static final String IMAGE = "image";//图片消息
+ /**
+ * 文本消息
+ */
+ public static final String TEXT = "text";
+ /**
+ * 图片消息
+ */
+ public static final String IMAGE = "image";
+ }
+
+ public static final class ErrorCode {
+ /**
+ * 40001 获取access_token时AppSecret错误,或者access_token无效
+ */
+ public static final int ERR_40001 = 40001;
+
+ /**
+ * 42001 access_token超时
+ */
+ public static final int ERR_42001 = 42001;
+
+ /**
+ * 40014 不合法的access_token,请开发者认真比对access_token的有效性(如是否过期)
+ */
+ public static final int ERR_40014 = 40014;
}
}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java
index cbe42b1f26..be3af708bd 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java
@@ -2,6 +2,7 @@
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaMessage;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
import me.chanjar.weixin.common.api.WxErrorExceptionHandler;
import me.chanjar.weixin.common.api.WxMessageDuplicateChecker;
import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker;
@@ -17,10 +18,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
+import java.util.concurrent.*;
/**
* @author Binary Wang
@@ -42,7 +40,9 @@ public class WxMaMessageRouter {
public WxMaMessageRouter(WxMaService wxMaService) {
this.wxMaService = wxMaService;
- this.executorService = Executors.newFixedThreadPool(DEFAULT_THREAD_POOL_SIZE);
+ ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("WxMaMessageRouter-pool-%d").build();
+ this.executorService = new ThreadPoolExecutor(DEFAULT_THREAD_POOL_SIZE, DEFAULT_THREAD_POOL_SIZE,
+ 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), namedThreadFactory);
this.messageDuplicateChecker = new WxMessageInMemoryDuplicateChecker();
this.sessionManager = new StandardSessionManager();
this.exceptionHandler = new LogExceptionHandler();
@@ -159,7 +159,7 @@ public void run() {
}
public void route(final WxMaMessage wxMessage) {
- this.route(wxMessage, new HashMap());
+ this.route(wxMessage, new HashMap(2));
}
/**
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java
index 835eb2894a..5353652995 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java
@@ -196,7 +196,7 @@ protected void service(WxMaMessage wxMessage,
WxSessionManager sessionManager,
WxErrorExceptionHandler exceptionHandler) {
if (context == null) {
- context = new HashMap<>();
+ context = new HashMap<>(16);
}
try {
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java
index 3c026f4a18..9b35df8957 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java
@@ -1,6 +1,6 @@
package cn.binarywang.wx.miniapp.util.http;
-import cn.binarywang.wx.miniapp.bean.WxMaQrcodeWrapper;
+import cn.binarywang.wx.miniapp.bean.AbstractWxMaQrcodeWrapper;
import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.fs.FileUtils;
@@ -25,7 +25,7 @@
/**
* @author Binary Wang
*/
-public class QrCodeRequestExecutor implements RequestExecutor {
+public class QrCodeRequestExecutor implements RequestExecutor {
protected RequestHttp requestHttp;
public QrCodeRequestExecutor(RequestHttp requestHttp) {
@@ -33,14 +33,12 @@ public QrCodeRequestExecutor(RequestHttp requestHttp) {
}
@Override
- public File execute(String uri, WxMaQrcodeWrapper ticket) throws WxErrorException, IOException {
+ public File execute(String uri, AbstractWxMaQrcodeWrapper ticket) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
- httpPost
- .setConfig(RequestConfig.custom()
- .setProxy(requestHttp.getRequestHttpProxy())
- .build()
- );
+ httpPost.setConfig(
+ RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build()
+ );
}
httpPost.setEntity(new StringEntity(ticket.toString()));
@@ -48,7 +46,8 @@ public File execute(String uri, WxMaQrcodeWrapper ticket) throws WxErrorExceptio
InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response);) {
Header[] contentTypeHeader = response.getHeaders("Content-Type");
if (contentTypeHeader != null && contentTypeHeader.length > 0
- && ContentType.APPLICATION_JSON.getMimeType().equals(contentTypeHeader[0].getValue())) {
+ && ContentType.APPLICATION_JSON.getMimeType()
+ .equals(ContentType.parse(contentTypeHeader[0].getValue()).getMimeType())) {
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
throw new WxErrorException(WxError.fromJson(responseContent));
}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java
index f85c716acb..578bf68c71 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java
@@ -18,7 +18,7 @@ public class XStreamTransformer {
}
/**
- * xml -> pojo
+ * xml -> pojo.
*/
@SuppressWarnings("unchecked")
public static T fromXml(Class clazz, String xml) {
@@ -33,14 +33,14 @@ public static T fromXml(Class clazz, InputStream is) {
}
/**
- * pojo -> xml
+ * pojo -> xml.
*/
public static String toXml(Class clazz, T object) {
return CLASS_2_XSTREAM_INSTANCE.get(clazz).toXML(object);
}
/**
- * 注册扩展消息的解析器
+ * 注册扩展消息的解析器.
*
* @param clz 类型
* @param xStream xml解析器
@@ -50,12 +50,14 @@ private static void register(Class> clz, XStream xStream) {
}
/**
- * 会自动注册该类及其子类
+ * 会自动注册该类及其子类.
*
* @param clz 要注册的类
*/
private static void registerClass(Class> clz) {
XStream xstream = XStreamInitializer.getInstance();
+ xstream.setClassLoader(Thread.currentThread().getContextClassLoader());
+
xstream.processAnnotations(clz);
xstream.processAnnotations(getInnerClasses(clz));
if (clz.equals(WxMaMessage.class)) {
diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java
index 37e3608bff..d6aa31a71f 100644
--- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java
+++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java
@@ -31,7 +31,7 @@ public void testSendKefuMpNewsMessage() throws WxErrorException {
TestConfig configStorage = (TestConfig) this.wxService
.getWxMaConfig();
WxMaKefuMessage message = new WxMaKefuMessage();
- message.setMsgType(WxConsts.CUSTOM_MSG_MPNEWS);
+ message.setMsgType(WxConsts.KefuMsgType.MPNEWS);
message.setToUser(configStorage.getOpenid());
this.wxService.getMsgService().sendKefuMsg(message);
@@ -41,7 +41,7 @@ public void testSendKefuMessage() throws WxErrorException {
TestConfig config = (TestConfig) this.wxService
.getWxMaConfig();
WxMaKefuMessage message = new WxMaKefuMessage();
- message.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
+ message.setMsgType(WxConsts.KefuMsgType.TEXT);
message.setToUser(config.getOpenid());
message.setContent(
"欢迎欢迎,热烈欢迎\n换行测试\n超链接:Hello World");
@@ -54,7 +54,7 @@ public void testSendTemplateMsg() throws WxErrorException {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
TestConfig config = (TestConfig) this.wxService.getWxMaConfig();
- WxMaTemplateMessage templateMessage = WxMaTemplateMessage.newBuilder()
+ WxMaTemplateMessage templateMessage = WxMaTemplateMessage.builder()
.toUser(config.getOpenid())
.formId("FORMID")
.page("index")
diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessageTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessageTest.java
index f2ef8bfac5..667ab2de63 100644
--- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessageTest.java
+++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessageTest.java
@@ -13,26 +13,26 @@ public class WxMaKefuMessageTest {
public void testTextReply() {
WxMaKefuMessage reply = new WxMaKefuMessage();
reply.setToUser("OPENID");
- reply.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
+ reply.setMsgType(WxConsts.KefuMsgType.TEXT);
reply.setContent("sfsfdsdf");
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}");
}
public void testTextBuild() {
- WxMaKefuMessage reply = WxMaKefuMessage.TEXT().toUser("OPENID").content("sfsfdsdf").build();
+ WxMaKefuMessage reply = WxMaKefuMessage.newTextBuilder().toUser("OPENID").content("sfsfdsdf").build();
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}");
}
public void testImageReply() {
WxMaKefuMessage reply = new WxMaKefuMessage();
reply.setToUser("OPENID");
- reply.setMsgType(WxConsts.CUSTOM_MSG_IMAGE);
+ reply.setMsgType(WxConsts.KefuMsgType.IMAGE);
reply.setMediaId("MEDIA_ID");
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}");
}
public void testImageBuild() {
- WxMaKefuMessage reply = WxMaKefuMessage.IMAGE().toUser("OPENID").mediaId("MEDIA_ID").build();
+ WxMaKefuMessage reply = WxMaKefuMessage.newImageBuilder().toUser("OPENID").mediaId("MEDIA_ID").build();
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}");
}
diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java
index cdf989a6af..fa7d3ebb92 100644
--- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java
+++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java
@@ -60,7 +60,7 @@ public void testFromXml() {
assertEquals(wxMessage.getToUser(), "toUser");
assertEquals(wxMessage.getFromUser(), "fromUser");
assertEquals(wxMessage.getCreateTime(), new Long(1348831860L));
- assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT);
+ assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT);
assertEquals(wxMessage.getContent(), "this is a test");
assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L));
assertEquals(wxMessage.getPicUrl(), "this is a url");
@@ -118,7 +118,7 @@ public void testFromXml2() {
assertEquals(wxMessage.getToUser(), "toUser");
assertEquals(wxMessage.getFromUser(), "fromUser");
assertEquals(wxMessage.getCreateTime(), new Integer(1348831860));
- assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT);
+ assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT);
assertEquals(wxMessage.getContent(), "this is a test");
assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L));
assertEquals(wxMessage.getPicUrl(), "this is a url");
diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessageTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessageTest.java
index ad6e62c2ca..d4464312eb 100644
--- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessageTest.java
+++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessageTest.java
@@ -11,7 +11,7 @@
public class WxMaTemplateMessageTest {
@Test
public void testToJson() throws Exception {
- WxMaTemplateMessage tm = WxMaTemplateMessage.newBuilder()
+ WxMaTemplateMessage tm = WxMaTemplateMessage.builder()
.toUser("OPENID")
//.color("aaaaa")
.formId("FORMID")
diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/demo/WxMaDemoServer.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/demo/WxMaDemoServer.java
index f6dcbae27b..8d14b261ff 100644
--- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/demo/WxMaDemoServer.java
+++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/demo/WxMaDemoServer.java
@@ -34,7 +34,7 @@ public class WxMaDemoServer {
public void handle(WxMaMessage wxMessage, Map context,
WxMaService service, WxSessionManager sessionManager) throws WxErrorException {
System.out.println("收到消息:" + wxMessage.toString());
- service.getMsgService().sendKefuMsg(WxMaKefuMessage.TEXT().content("收到信息为:" + wxMessage.toJson())
+ service.getMsgService().sendKefuMsg(WxMaKefuMessage.newTextBuilder().content("收到信息为:" + wxMessage.toJson())
.toUser(wxMessage.getFromUser()).build());
}
};
@@ -44,7 +44,7 @@ public void handle(WxMaMessage wxMessage, Map context,
public void handle(WxMaMessage wxMessage, Map context,
WxMaService service, WxSessionManager sessionManager)
throws WxErrorException {
- service.getMsgService().sendKefuMsg(WxMaKefuMessage.TEXT().content("回复文本消息")
+ service.getMsgService().sendKefuMsg(WxMaKefuMessage.newTextBuilder().content("回复文本消息")
.toUser(wxMessage.getFromUser()).build());
}
@@ -60,7 +60,7 @@ public void handle(WxMaMessage wxMessage, Map context,
ClassLoader.getSystemResourceAsStream("tmp.png"));
service.getMsgService().sendKefuMsg(
WxMaKefuMessage
- .IMAGE()
+ .newImageBuilder()
.mediaId(uploadResult.getMediaId())
.toUser(wxMessage.getFromUser())
.build());
@@ -79,7 +79,7 @@ public void handle(WxMaMessage wxMessage, Map context,
WxMediaUploadResult uploadResult = service.getMediaService().uploadMedia(WxMaConstants.MediaType.IMAGE, file);
service.getMsgService().sendKefuMsg(
WxMaKefuMessage
- .IMAGE()
+ .newImageBuilder()
.mediaId(uploadResult.getMediaId())
.toUser(wxMessage.getFromUser())
.build());
@@ -94,7 +94,7 @@ public void handle(WxMaMessage wxMessage, Map context,
public void handle(WxMaMessage wxMessage, Map context,
WxMaService service, WxSessionManager sessionManager)
throws WxErrorException {
- service.getMsgService().sendTemplateMsg(WxMaTemplateMessage.newBuilder()
+ service.getMsgService().sendTemplateMsg(WxMaTemplateMessage.builder()
.templateId(templateId).data(Lists.newArrayList(
new WxMaTemplateMessage.Data("keyword1", "339208499", "#173177")))
.toUser(wxMessage.getFromUser())
diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml
index 81ec2c01ab..a135b6dda6 100644
--- a/weixin-java-mp/pom.xml
+++ b/weixin-java-mp/pom.xml
@@ -7,7 +7,7 @@
com.github.binarywang
weixin-java-parent
- 2.8.0
+ 2.9.0
weixin-java-mp
WeiXin Java Tools - MP
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInRedisConfigStorage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInRedisConfigStorage.java
index d22214dfa1..6974221c10 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInRedisConfigStorage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInRedisConfigStorage.java
@@ -1,11 +1,15 @@
package me.chanjar.weixin.mp.api;
import redis.clients.jedis.Jedis;
+import redis.clients.jedis.JedisPool;
/**
* 基于Redis的微信配置provider
- *
- * @author lly835
+ *
+ * 使用说明:本实现仅供参考,并不完整,
+ * 比如为减少项目依赖,未加入redis分布式锁的实现,如有需要请自行实现。
+ *
+ * @author nickwong
*/
@SuppressWarnings("hiding")
public class WxMpInRedisConfigStorage extends WxMpInMemoryConfigStorage {
@@ -16,75 +20,115 @@ public class WxMpInRedisConfigStorage extends WxMpInMemoryConfigStorage {
private final static String CARDAPI_TICKET_KEY = "wechat_cardapi_ticket_";
- protected Jedis jedis;
+ /**
+ * 使用连接池保证线程安全
+ */
+ protected final JedisPool jedisPool;
+
+ private String accessTokenKey;
+
+ private String jsapiTicketKey;
+
+ private String cardapiTicketKey;
+
+ public WxMpInRedisConfigStorage(JedisPool jedisPool) {
+ this.jedisPool = jedisPool;
+ }
+
+ /**
+ * 每个公众号生成独有的存储key
+ *
+ * @param appId
+ */
+ @Override
+ public void setAppId(String appId) {
+ super.setAppId(appId);
+ this.accessTokenKey = ACCESS_TOKEN_KEY.concat(appId);
+ this.jsapiTicketKey = JSAPI_TICKET_KEY.concat(appId);
+ this.cardapiTicketKey = CARDAPI_TICKET_KEY.concat(appId);
+ }
@Override
public String getAccessToken() {
- return jedis.get(ACCESS_TOKEN_KEY.concat(appId));
+ try (Jedis jedis = this.jedisPool.getResource()) {
+ return jedis.get(accessTokenKey);
+ }
}
@Override
public boolean isAccessTokenExpired() {
- return jedis.ttl(ACCESS_TOKEN_KEY.concat(appId)) < 2;
+ try (Jedis jedis = this.jedisPool.getResource()) {
+ return jedis.ttl(accessTokenKey) < 2;
+ }
}
@Override
public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) {
- jedis.set(ACCESS_TOKEN_KEY.concat(appId), accessToken);
- jedis.expire(ACCESS_TOKEN_KEY.concat(appId), expiresInSeconds - 200);
+ try (Jedis jedis = this.jedisPool.getResource()) {
+ jedis.setex(accessTokenKey, expiresInSeconds - 200, accessToken);
+ }
}
@Override
public void expireAccessToken() {
- jedis.expire(ACCESS_TOKEN_KEY.concat(appId), 0);
+ try (Jedis jedis = this.jedisPool.getResource()) {
+ jedis.expire(accessTokenKey, 0);
+ }
}
@Override
public String getJsapiTicket() {
- return jedis.get(JSAPI_TICKET_KEY.concat(appId));
+ try (Jedis jedis = this.jedisPool.getResource()) {
+ return jedis.get(jsapiTicketKey);
+ }
}
@Override
public boolean isJsapiTicketExpired() {
- return jedis.ttl(JSAPI_TICKET_KEY.concat(appId)) < 2;
+ try (Jedis jedis = this.jedisPool.getResource()) {
+ return jedis.ttl(jsapiTicketKey) < 2;
+ }
}
@Override
public synchronized void updateJsapiTicket(String jsapiTicket, int expiresInSeconds) {
- jedis.set(JSAPI_TICKET_KEY.concat(appId), jsapiTicket);
- jedis.expire(JSAPI_TICKET_KEY.concat(appId), expiresInSeconds - 200);
+ try (Jedis jedis = this.jedisPool.getResource()) {
+ jedis.setex(jsapiTicketKey, expiresInSeconds - 200, jsapiTicket);
+ }
}
@Override
public void expireJsapiTicket() {
- jedis.expire(JSAPI_TICKET_KEY.concat(appId), 0);
+ try (Jedis jedis = this.jedisPool.getResource()) {
+ jedis.expire(jsapiTicketKey, 0);
+ }
}
- /**
- * 卡券api_ticket
- */
@Override
public String getCardApiTicket() {
- return jedis.get(CARDAPI_TICKET_KEY.concat(appId));
+ try (Jedis jedis = this.jedisPool.getResource()) {
+ return jedis.get(cardapiTicketKey);
+ }
}
@Override
public boolean isCardApiTicketExpired() {
- return jedis.ttl(CARDAPI_TICKET_KEY.concat(appId)) < 2;
+ try (Jedis jedis = this.jedisPool.getResource()) {
+ return jedis.ttl(cardapiTicketKey) < 2;
+ }
}
@Override
public synchronized void updateCardApiTicket(String cardApiTicket, int expiresInSeconds) {
- jedis.set(CARDAPI_TICKET_KEY.concat(appId), cardApiTicket);
- jedis.expire(CARDAPI_TICKET_KEY.concat(appId), expiresInSeconds - 200);
+ try (Jedis jedis = this.jedisPool.getResource()) {
+ jedis.setex(cardapiTicketKey, expiresInSeconds - 200, cardApiTicket);
+ }
}
@Override
public void expireCardApiTicket() {
- jedis.expire(CARDAPI_TICKET_KEY.concat(appId), 0);
- }
-
- public void setJedis(Jedis jedis) {
- this.jedis = jedis;
+ try (Jedis jedis = this.jedisPool.getResource()) {
+ jedis.expire(cardapiTicketKey, 0);
+ }
}
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java
index 36e13b13c4..9e0de39c4b 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java
@@ -92,11 +92,10 @@ public interface WxMpKefuService {
*
* 上传客服头像
* 详情请见:客服管理
- * 接口url格式:http://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT
+ * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT
*
*/
- boolean kfAccountUploadHeadImg(String kfAccount, File imgFile)
- throws WxErrorException;
+ boolean kfAccountUploadHeadImg(String kfAccount, File imgFile) throws WxErrorException;
/**
*
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java
index 6d1f025728..a7aacd544c 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java
@@ -94,7 +94,7 @@ public interface WxMpMassMessageService {
*
* @return wxMpMassSendResult
*/
- WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws Exception;
+ WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws WxErrorException;
/**
*
@@ -114,6 +114,6 @@ public interface WxMpMassMessageService {
* @param msgId 发送出去的消息ID
* @param articleIndex 要删除的文章在图文消息中的位置,第一篇编号为1,该字段不填或填0会删除全部文章
*/
- void delete(Integer msgId, Integer articleIndex) throws Exception;
+ void delete(Integer msgId, Integer articleIndex) throws WxErrorException;
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouter.java
index 5acf0040aa..6b7ddd08e2 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouter.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouter.java
@@ -10,6 +10,7 @@
import me.chanjar.weixin.common.util.LogExceptionHandler;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -195,16 +196,17 @@ public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage) {
}
protected boolean isMsgDuplicated(WxMpXmlMessage wxMessage) {
-
StringBuilder messageId = new StringBuilder();
if (wxMessage.getMsgId() == null) {
messageId.append(wxMessage.getCreateTime())
.append("-").append(wxMessage.getFromUser())
- .append("-").append(wxMessage.getEventKey() == null ? "" : wxMessage.getEventKey())
- .append("-").append(wxMessage.getEvent() == null ? "" : wxMessage.getEvent())
+ .append("-").append(StringUtils.trimToEmpty(wxMessage.getEventKey()))
+ .append("-").append(StringUtils.trimToEmpty(wxMessage.getEvent()))
;
} else {
- messageId.append(wxMessage.getMsgId());
+ messageId.append(wxMessage.getMsgId())
+ .append("-").append(wxMessage.getCreateTime())
+ .append("-").append(wxMessage.getFromUser());
}
return this.messageDuplicateChecker.isDuplicate(messageId.toString());
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java
index 914c902d44..0dd5a66bd3 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java
@@ -5,8 +5,11 @@
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
-import me.chanjar.weixin.mp.bean.*;
-import me.chanjar.weixin.mp.bean.result.*;
+import me.chanjar.weixin.mp.bean.WxMpSemanticQuery;
+import me.chanjar.weixin.mp.bean.result.WxMpCurrentAutoReplyInfo;
+import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
+import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult;
+import me.chanjar.weixin.mp.bean.result.WxMpUser;
/**
* 微信API的Service
@@ -62,6 +65,11 @@ public interface WxMpService {
*/
String GET_CURRENT_AUTOREPLY_INFO_URL = "https://api.weixin.qq.com/cgi-bin/get_current_autoreply_info";
+ /**
+ * 公众号调用或第三方平台帮公众号调用对公众号的所有api调用(包括第三方帮其调用)次数进行清零
+ */
+ String CLEAR_QUOTA_URL = "https://api.weixin.qq.com/cgi-bin/clear_quota";
+
/**
*
* 验证消息的确来自微信服务器
@@ -219,6 +227,18 @@ public interface WxMpService {
*/
WxMpCurrentAutoReplyInfo getCurrentAutoReplyInfo() throws WxErrorException;
+ /**
+ *
+ * 公众号调用或第三方平台帮公众号调用对公众号的所有api调用(包括第三方帮其调用)次数进行清零:
+ * HTTP调用:https://api.weixin.qq.com/cgi-bin/clear_quota?access_token=ACCESS_TOKEN
+ * 接口文档地址:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433744592
+ *
+ *
+ *
+ * @param appid 公众号的APPID
+ */
+ void clearQuota(String appid) throws WxErrorException;
+
/**
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求
*/
@@ -376,6 +396,7 @@ public interface WxMpService {
/**
* 返回群发消息相关接口方法的实现类对象,以方便调用其各个接口
+ *
* @return WxMpMassMessageService
*/
WxMpMassMessageService getMassMessageService();
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpShakeService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpShakeService.java
index 87a6747af5..697bfe899d 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpShakeService.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpShakeService.java
@@ -1,8 +1,10 @@
package me.chanjar.weixin.mp.api;
+import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.bean.WxMpShakeInfoResult;
import me.chanjar.weixin.mp.bean.WxMpShakeQuery;
+import me.chanjar.weixin.mp.bean.shake.*;
/**
* 摇一摇周边的相关接口
@@ -24,4 +26,36 @@ public interface WxMpShakeService {
*/
WxMpShakeInfoResult getShakeInfo(WxMpShakeQuery wxMpShakeQuery) throws WxErrorException;
+ /**
+ *
+ * 页面管理
+ * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1459246752
+ *
+ * @param shakeAroundPageAddQuery
+ * @return
+ * @throws WxErrorException
+ */
+ WxMpShakeAroundPageAddResult pageAdd(WxMpShakeAroundPageAddQuery shakeAroundPageAddQuery) throws WxErrorException;
+
+ /**
+ *
+ * 配置设备与页面的关联关系
+ * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1459301931
+ *
+ * @param shakeAroundDeviceBindPageQuery
+ * @return
+ * @throws WxErrorException
+ */
+ WxError deviceBindPageQuery(WxMpShakeAroundDeviceBindPageQuery shakeAroundDeviceBindPageQuery) throws WxErrorException;
+
+ /**
+ *
+ * 查询设备与页面的关联关系
+ * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1443447914
+ *
+ * @param shakeAroundRelationSearchQuery
+ * @return
+ * @throws WxErrorException
+ */
+ WxMpShakeAroundRelationSearchResult relationSearch(WxMpShakeAroundRelationSearchQuery shakeAroundRelationSearchQuery) throws WxErrorException;
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java
index 2634c3f36c..fa349c93b2 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java
@@ -9,11 +9,19 @@
/**
* 门店管理的相关接口代码
+ *
+ * Created by Binary Wang on 2016-09-23.
*
- * @author binarywang(Binary Wang)
- * Created by Binary Wang on 2016-09-23.
+ * @author Binary Wang
*/
public interface WxMpStoreService {
+ String POI_GET_WX_CATEGORY_URL = "https://api.weixin.qq.com/cgi-bin/poi/getwxcategory";
+ String POI_UPDATE_URL = "https://api.weixin.qq.com/cgi-bin/poi/updatepoi";
+ String POI_LIST_URL = "https://api.weixin.qq.com/cgi-bin/poi/getpoilist";
+ String POI_DEL_URL = "https://api.weixin.qq.com/cgi-bin/poi/delpoi";
+ String POI_GET_URL = "https://api.weixin.qq.com/cgi-bin/poi/getpoi";
+ String POI_ADD_URL = "https://api.weixin.qq.com/cgi-bin/poi/addpoi";
+
/**
*
* 创建门店
@@ -22,7 +30,7 @@ public interface WxMpStoreService {
* 创建门店接口调用成功后会返回errcode 0、errmsg ok,但不会实时返回poi_id。
* 成功创建后,会生成poi_id,但该id不一定为最终id。门店信息会经过审核,审核通过后方可获取最终poi_id,该id为门店的唯一id,强烈建议自行存储审核通过后的最终poi_id,并为后续调用使用。
* 详情请见: 微信门店接口
- * 接口格式: http://api.weixin.qq.com/cgi-bin/poi/addpoi?access_token=TOKEN
+ * 接口格式: https://api.weixin.qq.com/cgi-bin/poi/addpoi?access_token=TOKEN
*
*/
void add(WxMpStoreBaseInfo request) throws WxErrorException;
@@ -35,11 +43,10 @@ public interface WxMpStoreService {
* 最终结果会在5 个工作日内,最终确认是否采纳,并前端生效(但该扩展字段的采纳过程不影响门店的可用性,即available_state仍为审核通过状态)
* 注:扩展字段为公共编辑信息(大家都可修改),修改将会审核,并决定是否对修改建议进行采纳,但不会影响该门店的生效可用状态。
* 详情请见: 微信门店接口
- * 接口格式:http://api.weixin.qq.com/cgi-bin/poi/getpoi?access_token=TOKEN
+ * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/getpoi?access_token=TOKEN
*
*
* @param poiId 门店Id
- * @throws WxErrorException
*/
WxMpStoreBaseInfo get(String poiId) throws WxErrorException;
@@ -48,11 +55,10 @@ public interface WxMpStoreService {
* 删除门店
* 商户可以通过该接口,删除已经成功创建的门店。请商户慎重调用该接口。
* 详情请见: 微信门店接口
- * 接口格式:http://api.weixin.qq.com/cgi-bin/poi/delpoi?access_token=TOKEN
+ * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/delpoi?access_token=TOKEN
*
*
* @param poiId 门店Id
- * @throws WxErrorException
*/
void delete(String poiId) throws WxErrorException;
@@ -61,12 +67,11 @@ public interface WxMpStoreService {
* 查询门店列表(指定查询起始位置和个数)
* 商户可以通过该接口,批量查询自己名下的门店list,并获取已审核通过的poi_id(所有状态均会返回poi_id,但该poi_id不一定为最终id)、商户自身sid 用于对应、商户名、分店名、地址字段。
* 详情请见: 微信门店接口
- * 接口格式:http://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token=TOKEN
+ * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token=TOKEN
*
*
* @param begin 开始位置,0 即为从第一条开始查询
* @param limit 返回数据条数,最大允许50,默认为20
- * @throws WxErrorException
*/
WxMpStoreListResult list(int begin, int limit) throws WxErrorException;
@@ -75,10 +80,8 @@ public interface WxMpStoreService {
* 查询门店列表(所有)
* 商户可以通过该接口,批量查询自己名下的门店list,并获取已审核通过的poi_id(所有状态均会返回poi_id,但该poi_id不一定为最终id)、商户自身sid 用于对应、商户名、分店名、地址字段。
* 详情请见: 微信门店接口
- * 接口格式:http://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token=TOKEN
+ * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token=TOKEN
*
- *
- * @throws WxErrorException
*/
List* 默认接口实现类,使用apache httpclient实现 * Created by Binary Wang on 2017-5-27. - * @author binarywang(Binary Wang) *+ * + * @author Binary Wang */ public class WxMpServiceImpl extends WxMpServiceApacheHttpClientImpl { } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java index 9066dc8d17..b5135cebcb 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java @@ -5,19 +5,13 @@ import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.http.HttpType; import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; -import me.chanjar.weixin.mp.api.WxMpConfigStorage; import me.chanjar.weixin.mp.api.WxMpService; import okhttp3.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.concurrent.locks.Lock; public class WxMpServiceOkHttpImpl extends WxMpServiceAbstractImpl
* Created by Binary Wang on 2016-10-14. - * @author binarywang(Binary Wang) *+ * + * @author Binary Wang */ public class WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService { public static final String API_URL_PREFIX = "https://api.weixin.qq.com/cgi-bin/template"; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImpl.java index 99f271065c..e5357b1ed7 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImpl.java @@ -16,8 +16,9 @@ import java.util.List; /** - * @author binarywang(Binary Wang) - * Created by Binary Wang on 2016/9/2. + * Created by Binary Wang on 2016/9/2. + * + * @author Binary Wang */ public class WxMpUserTagServiceImpl implements WxMpUserTagService { private static final String API_URL_PREFIX = "https://api.weixin.qq.com/cgi-bin/tags"; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpCard.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpCard.java index 76fc4a6451..0fcb9185ee 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpCard.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpCard.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import java.io.Serializable; @@ -11,6 +12,7 @@ * @author YuJian * @version 15/11/11 */ +@Data public class WxMpCard implements Serializable{ private static final long serialVersionUID = 9214301870017772921L; @@ -24,46 +26,6 @@ public class WxMpCard implements Serializable{ private Boolean canConsume; - public String getCardId() { - return this.cardId; - } - - public void setCardId(String cardId) { - this.cardId = cardId; - } - - public Long getBeginTime() { - return this.beginTime; - } - - public void setBeginTime(Long beginTime) { - this.beginTime = beginTime; - } - - public Long getEndTime() { - return this.endTime; - } - - public void setEndTime(Long endTime) { - this.endTime = endTime; - } - - public String getUserCardStatus() { - return this.userCardStatus; - } - - public void setUserCardStatus(String userCardStatus) { - this.userCardStatus = userCardStatus; - } - - public Boolean getCanConsume() { - return this.canConsume; - } - - public void setCanConsume(Boolean canConsume) { - this.canConsume = canConsume; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassNews.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassNews.java index bb19f0e79e..b2ef87b1d6 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassNews.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassNews.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -12,15 +13,12 @@ * * @author chanjarster */ +@Data public class WxMpMassNews implements Serializable { private static final long serialVersionUID = 565937155013581016L; private List
* 请使用
- * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_IMAGE}
- * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_NEWS}
- * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_TEXT}
- * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VIDEO}
- * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE}
+ * {@link WxConsts.MassMsgType#IMAGE}
+ * {@link WxConsts.MassMsgType#MPNEWS}
+ * {@link WxConsts.MassMsgType#TEXT}
+ * {@link WxConsts.MassMsgType#MPVIDEO}
+ * {@link WxConsts.MassMsgType#VOICE}
* 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
*
- *
- * @param msgType
*/
- public void setMsgType(String msgType) {
- this.msgType = msgType;
- }
-
- public String getContent() {
- return this.content;
- }
-
- public void setContent(String content) {
- this.content = content;
- }
-
- public String getMediaId() {
- return this.mediaId;
- }
+ private String msgType;
+ private String content;
+ private String mediaId;
+ /**
+ * 文章被判定为转载时,是否继续进行群发操作。
+ */
+ private boolean sendIgnoreReprint = false;
- public void setMediaId(String mediaId) {
- this.mediaId = mediaId;
+ public WxMpMassOpenIdsMessage() {
+ super();
}
public String toJson() {
return WxMpGsonBuilder.INSTANCE.create().toJson(this);
}
- /**
- * openid列表,最多支持10,000个
- */
- public List
+ * 消息类型
* 请使用
- * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_IMAGE}
- * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_NEWS}
- * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_TEXT}
- * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VIDEO}
- * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE}
+ * {@link WxConsts.MassMsgType#IMAGE}
+ * {@link WxConsts.MassMsgType#MPNEWS}
+ * {@link WxConsts.MassMsgType#TEXT}
+ * {@link WxConsts.MassMsgType#MPVIDEO}
+ * {@link WxConsts.MassMsgType#VOICE}
* 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
*
- *
- * @param msgType 消息类型
*/
- public void setMsgType(String msgType) {
- this.msgType = msgType;
- }
-
- public String getContent() {
- return this.content;
- }
-
- public void setContent(String content) {
- this.content = content;
- }
-
- public String getMediaId() {
- return this.mediaId;
- }
-
- public void setMediaId(String mediaId) {
- this.mediaId = mediaId;
- }
-
- public String getToWxUserOpenid() {
- return this.toWxUserOpenid;
- }
+ private String msgType;
+ private String content;
+ private String mediaId;
- public void setToWxUserOpenid(String toWxUserOpenid) {
- this.toWxUserOpenid = toWxUserOpenid;
+ public WxMpMassPreviewMessage() {
+ super();
}
public String toJson() {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java
index acf9d0f4c1..5bcd408441 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java
@@ -1,5 +1,7 @@
package me.chanjar.weixin.mp.bean;
+import lombok.Data;
+import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
import java.io.Serializable;
@@ -9,90 +11,44 @@
*
* @author chanjarster
*/
+@Data
public class WxMpMassTagMessage implements Serializable {
private static final long serialVersionUID = -6625914040986749286L;
+ /**
+ * 标签id,如果不设置则就意味着发给所有用户
+ */
private Long tagId;
- private String msgType;
- private String content;
- private String mediaId;
- private boolean isSendAll = false;
- private boolean sendIgnoreReprint = false;
-
- public WxMpMassTagMessage() {
- super();
- }
-
- public String getMsgType() {
- return this.msgType;
- }
-
/**
*
+ * 消息类型
* 请使用
- * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_IMAGE}
- * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_NEWS}
- * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_TEXT}
- * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VIDEO}
- * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE}
+ * {@link WxConsts.MassMsgType#IMAGE}
+ * {@link WxConsts.MassMsgType#MPNEWS}
+ * {@link WxConsts.MassMsgType#TEXT}
+ * {@link WxConsts.MassMsgType#MPVIDEO}
+ * {@link WxConsts.MassMsgType#VOICE}
* 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
*
- *
- * @param msgType 消息类型
*/
- public void setMsgType(String msgType) {
- this.msgType = msgType;
- }
-
- public String getContent() {
- return this.content;
- }
-
- public void setContent(String content) {
- this.content = content;
- }
-
- public String getMediaId() {
- return this.mediaId;
- }
-
- public void setMediaId(String mediaId) {
- this.mediaId = mediaId;
- }
-
- public String toJson() {
- return WxMpGsonBuilder.INSTANCE.create().toJson(this);
- }
-
- public Long getTagId() {
- return this.tagId;
- }
-
+ private String msgType;
+ private String content;
+ private String mediaId;
/**
- * 如果不设置则就意味着发给所有用户
- *
- * @param tagId 标签id
+ * 是否群发给所有用户
*/
- public void setTagId(Long tagId) {
- this.tagId = tagId;
- }
-
- public boolean isSendIgnoreReprint() {
- return sendIgnoreReprint;
- }
-
+ private boolean isSendAll = false;
/**
- * @param sendIgnoreReprint 文章被判定为转载时,是否继续进行群发操作。
+ * 文章被判定为转载时,是否继续进行群发操作。
*/
- public void setSendIgnoreReprint(boolean sendIgnoreReprint) {
- this.sendIgnoreReprint = sendIgnoreReprint;
+ private boolean sendIgnoreReprint = false;
+
+ public WxMpMassTagMessage() {
+ super();
}
- /**
- * 是否群发给所有用户
- */
- public boolean isSendAll() {
- return isSendAll;
+ public String toJson() {
+ return WxMpGsonBuilder.INSTANCE.create().toJson(this);
}
public void setSendAll(boolean sendAll) {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassVideo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassVideo.java
index 1683be5bdf..d536ff989f 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassVideo.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassVideo.java
@@ -1,5 +1,6 @@
package me.chanjar.weixin.mp.bean;
+import lombok.Data;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
import java.io.Serializable;
@@ -9,6 +10,7 @@
*
* @author chanjarster
*/
+@Data
public class WxMpMassVideo implements Serializable {
private static final long serialVersionUID = 9153925016061915637L;
@@ -16,30 +18,6 @@ public class WxMpMassVideo implements Serializable {
private String title;
private String description;
- public String getTitle() {
- return this.title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getMediaId() {
- return this.mediaId;
- }
-
- public void setMediaId(String mediaId) {
- this.mediaId = mediaId;
- }
-
public String toJson() {
return WxMpGsonBuilder.INSTANCE.create().toJson(this);
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpSemanticQuery.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpSemanticQuery.java
index 8c18a6a9ea..f9de30f552 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpSemanticQuery.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpSemanticQuery.java
@@ -1,5 +1,6 @@
package me.chanjar.weixin.mp.bean;
+import lombok.Data;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
import java.io.Serializable;
@@ -11,6 +12,7 @@
*
* @author Daniel Qian
*/
+@Data
public class WxMpSemanticQuery implements Serializable {
private static final long serialVersionUID = 7685873048199870690L;
@@ -23,70 +25,6 @@ public class WxMpSemanticQuery implements Serializable {
private String appid;
private String uid;
- public String getQuery() {
- return this.query;
- }
-
- public void setQuery(String query) {
- this.query = query;
- }
-
- public String getCategory() {
- return this.category;
- }
-
- public void setCategory(String category) {
- this.category = category;
- }
-
- public Float getLatitude() {
- return this.latitude;
- }
-
- public void setLatitude(Float latitude) {
- this.latitude = latitude;
- }
-
- public Float getLongitude() {
- return this.longitude;
- }
-
- public void setLongitude(Float longitude) {
- this.longitude = longitude;
- }
-
- public String getCity() {
- return this.city;
- }
-
- public void setCity(String city) {
- this.city = city;
- }
-
- public String getRegion() {
- return this.region;
- }
-
- public void setRegion(String region) {
- this.region = region;
- }
-
- public String getAppid() {
- return this.appid;
- }
-
- public void setAppid(String appid) {
- this.appid = appid;
- }
-
- public String getUid() {
- return this.uid;
- }
-
- public void setUid(String uid) {
- this.uid = uid;
- }
-
public String toJson() {
return WxMpGsonBuilder.create().toJson(this);
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeInfoResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeInfoResult.java
index 5fb2ab1735..313cfaba84 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeInfoResult.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeInfoResult.java
@@ -1,5 +1,6 @@
package me.chanjar.weixin.mp.bean;
+import lombok.Data;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
import java.io.Serializable;
@@ -10,6 +11,7 @@
*
* @author rememberber
*/
+@Data
public class WxMpShakeInfoResult implements Serializable {
private static final long serialVersionUID = -1604561297395395468L;
@@ -17,13 +19,15 @@ public class WxMpShakeInfoResult implements Serializable {
private String errmsg;
- private Data data;
+ private ShakeInfoData data;
public static WxMpShakeInfoResult fromJson(String json) {
return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpShakeInfoResult.class);
}
- public class Data {
+ @Data
+ public class ShakeInfoData implements Serializable {
+ private static final long serialVersionUID = -4828142206067489488L;
private String page_id;
@@ -35,7 +39,9 @@ public class Data {
private BeaconInfo beacon_info;
- public class BeaconInfo {
+ @Data
+ public class BeaconInfo implements Serializable {
+ private static final long serialVersionUID = -8995733049982933362L;
private double distance;
@@ -48,118 +54,7 @@ public class BeaconInfo {
private Integer rssi;
private String uuid;
-
- public double getDistance() {
- return distance;
- }
-
- public void setDistance(double distance) {
- this.distance = distance;
- }
-
- public Integer getMajor() {
- return major;
- }
-
- public void setMajor(Integer major) {
- this.major = major;
- }
-
- public Integer getMeasure_power() {
- return measure_power;
- }
-
- public void setMeasure_power(Integer measure_power) {
- this.measure_power = measure_power;
- }
-
- public Integer getMinor() {
- return minor;
- }
-
- public void setMinor(Integer minor) {
- this.minor = minor;
- }
-
- public Integer getRssi() {
- return rssi;
- }
-
- public void setRssi(Integer rssi) {
- this.rssi = rssi;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
- }
-
- public String getPage_id() {
- return page_id;
- }
-
- public void setPage_id(String page_id) {
- this.page_id = page_id;
- }
-
- public String getOpenid() {
- return openid;
- }
-
- public void setOpenid(String openid) {
- this.openid = openid;
- }
-
- public String getPoi_id() {
- return poi_id;
- }
-
- public void setPoi_id(String poi_id) {
- this.poi_id = poi_id;
- }
-
- public BeaconInfo getBeacon_info() {
- return beacon_info;
- }
-
- public void setBeacon_info(BeaconInfo beacon_info) {
- this.beacon_info = beacon_info;
- }
-
- public String getBrand_userame() {
- return brand_userame;
- }
-
- public void setBrand_userame(String brand_userame) {
- this.brand_userame = brand_userame;
}
}
- public Integer getErrcode() {
- return errcode;
- }
-
- public void setErrcode(Integer errcode) {
- this.errcode = errcode;
- }
-
- public String getErrmsg() {
- return errmsg;
- }
-
- public void setErrmsg(String errmsg) {
- this.errmsg = errmsg;
- }
-
- public Data getData() {
- return data;
- }
-
- public void setData(Data data) {
- this.data = data;
- }
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeQuery.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeQuery.java
index 0f4aeadd19..709e59e50f 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeQuery.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeQuery.java
@@ -1,6 +1,7 @@
package me.chanjar.weixin.mp.bean;
import com.google.gson.Gson;
+import lombok.Data;
import java.io.Serializable;
import java.util.HashMap;
@@ -11,6 +12,7 @@
*
* @author rememberber
*/
+@Data
public class WxMpShakeQuery implements Serializable {
private static final long serialVersionUID = 4316527352035275412L;
@@ -25,19 +27,4 @@ public String toJsonString() {
return new Gson().toJson(map);
}
- public String getTicket() {
- return ticket;
- }
-
- public void setTicket(String ticket) {
- this.ticket = ticket;
- }
-
- public int getNeedPoi() {
- return needPoi;
- }
-
- public void setNeedPoi(int needPoi) {
- this.needPoi = needPoi;
- }
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpUserQuery.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpUserQuery.java
index 243163c28b..9e73b46159 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpUserQuery.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpUserQuery.java
@@ -1,6 +1,7 @@
package me.chanjar.weixin.mp.bean;
import com.google.gson.Gson;
+import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
@@ -14,6 +15,7 @@
*
* @author LiuJunGuang
*/
+@Data
public class WxMpUserQuery implements Serializable {
private static final long serialVersionUID = -1344224837373149313L;
@@ -110,19 +112,18 @@ public String toJsonString() {
}
// 查询参数封装
+ @Data
public class WxMpUserQueryParam implements Serializable {
private static final long serialVersionUID = -6863571795702385319L;
private String openid;
private String lang;
public WxMpUserQueryParam(String openid, String lang) {
- super();
this.openid = openid;
this.lang = lang;
}
public WxMpUserQueryParam(String openid) {
- super();
this.openid = openid;
this.lang = "zh_CN";
}
@@ -131,56 +132,6 @@ public WxMpUserQueryParam() {
super();
}
- public String getOpenid() {
- return this.openid;
- }
-
- public void setOpenid(String openid) {
- this.openid = openid;
- }
-
- public String getLang() {
- return this.lang;
- }
-
- public void setLang(String lang) {
- this.lang = lang;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + getOuterType().hashCode();
- result = prime * result + ((this.lang == null) ? 0 : this.lang.hashCode());
- result = prime * result + ((this.openid == null) ? 0 : this.openid.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- WxMpUserQueryParam other = (WxMpUserQueryParam) obj;
- if (!getOuterType().equals(other.getOuterType()))
- return false;
- if (this.lang == null) {
- if (other.lang != null)
- return false;
- } else if (!this.lang.equals(other.lang))
- return false;
- if (this.openid == null) {
- if (other.openid != null)
- return false;
- } else if (!this.openid.equals(other.openid))
- return false;
- return true;
- }
-
private WxMpUserQuery getOuterType() {
return WxMpUserQuery.this;
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java
index e6518064bb..3901c61fbc 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java
@@ -1,18 +1,22 @@
package me.chanjar.weixin.mp.bean.datacube;
-import com.google.gson.JsonParser;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
import java.util.List;
/**
* 图文分析数据接口返回结果对象
+ *
+ * Created by Binary Wang on 2016/8/24.
*
- * @author binarywang(Binary Wang)
- * Created by Binary Wang on 2016/8/24.
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
public class WxDataCubeArticleResult extends WxDataCubeBaseResult {
private static final long serialVersionUID = -9222452497954511765L;
@@ -116,107 +120,4 @@ public static List
+ * Created by Binary Wang on 2016/8/24.
*
- * @author binarywang(Binary Wang)
- * Created by Binary Wang on 2016/8/24.
+ * @author Binary Wang
*/
-public class WxDataCubeArticleTotalDetail implements Serializable{
+@Data
+public class WxDataCubeArticleTotalDetail implements Serializable {
private static final long serialVersionUID = -5136169129771430052L;
/**
@@ -195,215 +198,4 @@ public class WxDataCubeArticleTotalDetail implements Serializable{
@SerializedName("feed_share_from_other_cnt")
private Integer feedShareFromOtherCnt;
- public String getStatDate() {
- return this.statDate;
- }
-
- public void setStatDate(String statDate) {
- this.statDate = statDate;
- }
-
- public Integer getTargetUser() {
- return this.targetUser;
- }
-
- public void setTargetUser(Integer targetUser) {
- this.targetUser = targetUser;
- }
-
- public Integer getIntPageReadUser() {
- return this.intPageReadUser;
- }
-
- public void setIntPageReadUser(Integer intPageReadUser) {
- this.intPageReadUser = intPageReadUser;
- }
-
- public Integer getIntPageReadCount() {
- return this.intPageReadCount;
- }
-
- public void setIntPageReadCount(Integer intPageReadCount) {
- this.intPageReadCount = intPageReadCount;
- }
-
- public Integer getOriPageReadUser() {
- return this.oriPageReadUser;
- }
-
- public void setOriPageReadUser(Integer oriPageReadUser) {
- this.oriPageReadUser = oriPageReadUser;
- }
-
- public Integer getOriPageReadCount() {
- return this.oriPageReadCount;
- }
-
- public void setOriPageReadCount(Integer oriPageReadCount) {
- this.oriPageReadCount = oriPageReadCount;
- }
-
- public Integer getShareUser() {
- return this.shareUser;
- }
-
- public void setShareUser(Integer shareUser) {
- this.shareUser = shareUser;
- }
-
- public Integer getShareCount() {
- return this.shareCount;
- }
-
- public void setShareCount(Integer shareCount) {
- this.shareCount = shareCount;
- }
-
- public Integer getAddToFavUser() {
- return this.addToFavUser;
- }
-
- public void setAddToFavUser(Integer addToFavUser) {
- this.addToFavUser = addToFavUser;
- }
-
- public Integer getAddToFavCount() {
- return this.addToFavCount;
- }
-
- public void setAddToFavCount(Integer addToFavCount) {
- this.addToFavCount = addToFavCount;
- }
-
- public Integer getIntPageFromSessionReadUser() {
- return this.intPageFromSessionReadUser;
- }
-
- public void setIntPageFromSessionReadUser(Integer intPageFromSessionReadUser) {
- this.intPageFromSessionReadUser = intPageFromSessionReadUser;
- }
-
- public Integer getIntPageFromSessionReadCount() {
- return this.intPageFromSessionReadCount;
- }
-
- public void setIntPageFromSessionReadCount(
- Integer intPageFromSessionReadCount) {
- this.intPageFromSessionReadCount = intPageFromSessionReadCount;
- }
-
- public Integer getIntPageFromHistMsgReadUser() {
- return this.intPageFromHistMsgReadUser;
- }
-
- public void setIntPageFromHistMsgReadUser(Integer intPageFromHistMsgReadUser) {
- this.intPageFromHistMsgReadUser = intPageFromHistMsgReadUser;
- }
-
- public Integer getIntPageFromHistMsgReadCount() {
- return this.intPageFromHistMsgReadCount;
- }
-
- public void setIntPageFromHistMsgReadCount(
- Integer intPageFromHistMsgReadCount) {
- this.intPageFromHistMsgReadCount = intPageFromHistMsgReadCount;
- }
-
- public Integer getIntPageFromFeedReadUser() {
- return this.intPageFromFeedReadUser;
- }
-
- public void setIntPageFromFeedReadUser(Integer intPageFromFeedReadUser) {
- this.intPageFromFeedReadUser = intPageFromFeedReadUser;
- }
-
- public Integer getIntPageFromFeedReadCount() {
- return this.intPageFromFeedReadCount;
- }
-
- public void setIntPageFromFeedReadCount(Integer intPageFromFeedReadCount) {
- this.intPageFromFeedReadCount = intPageFromFeedReadCount;
- }
-
- public Integer getIntPageFromFriendsReadUser() {
- return this.intPageFromFriendsReadUser;
- }
-
- public void setIntPageFromFriendsReadUser(Integer intPageFromFriendsReadUser) {
- this.intPageFromFriendsReadUser = intPageFromFriendsReadUser;
- }
-
- public Integer getIntPageFromFriendsReadCount() {
- return this.intPageFromFriendsReadCount;
- }
-
- public void setIntPageFromFriendsReadCount(
- Integer intPageFromFriendsReadCount) {
- this.intPageFromFriendsReadCount = intPageFromFriendsReadCount;
- }
-
- public Integer getIntPageFromOtherReadUser() {
- return this.intPageFromOtherReadUser;
- }
-
- public void setIntPageFromOtherReadUser(Integer intPageFromOtherReadUser) {
- this.intPageFromOtherReadUser = intPageFromOtherReadUser;
- }
-
- public Integer getIntPageFromOtherReadCount() {
- return this.intPageFromOtherReadCount;
- }
-
- public void setIntPageFromOtherReadCount(Integer intPageFromOtherReadCount) {
- this.intPageFromOtherReadCount = intPageFromOtherReadCount;
- }
-
- public Integer getFeedShareFromSessionUser() {
- return this.feedShareFromSessionUser;
- }
-
- public void setFeedShareFromSessionUser(Integer feedShareFromSessionUser) {
- this.feedShareFromSessionUser = feedShareFromSessionUser;
- }
-
- public Integer getFeedShareFromSessionCnt() {
- return this.feedShareFromSessionCnt;
- }
-
- public void setFeedShareFromSessionCnt(Integer feedShareFromSessionCnt) {
- this.feedShareFromSessionCnt = feedShareFromSessionCnt;
- }
-
- public Integer getFeedShareFromFeedUser() {
- return this.feedShareFromFeedUser;
- }
-
- public void setFeedShareFromFeedUser(Integer feedShareFromFeedUser) {
- this.feedShareFromFeedUser = feedShareFromFeedUser;
- }
-
- public Integer getFeedShareFromFeedCnt() {
- return this.feedShareFromFeedCnt;
- }
-
- public void setFeedShareFromFeedCnt(Integer feedShareFromFeedCnt) {
- this.feedShareFromFeedCnt = feedShareFromFeedCnt;
- }
-
- public Integer getFeedShareFromOtherUser() {
- return this.feedShareFromOtherUser;
- }
-
- public void setFeedShareFromOtherUser(Integer feedShareFromOtherUser) {
- this.feedShareFromOtherUser = feedShareFromOtherUser;
- }
-
- public Integer getFeedShareFromOtherCnt() {
- return this.feedShareFromOtherCnt;
- }
-
- public void setFeedShareFromOtherCnt(Integer feedShareFromOtherCnt) {
- this.feedShareFromOtherCnt = feedShareFromOtherCnt;
- }
-
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java
index cfc8636143..df86ab4e15 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java
@@ -2,24 +2,26 @@
import com.google.gson.JsonParser;
import com.google.gson.annotations.SerializedName;
+import lombok.Data;
import me.chanjar.weixin.common.util.ToStringUtils;
import java.io.Serializable;
/**
*
+ * Created by Binary Wang on 2016/8/30.
*
- * @author binarywang(Binary Wang)
- * Created by Binary Wang on 2016/8/30.
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
public class WxDataCubeInterfaceResult extends WxDataCubeBaseResult {
private static final long serialVersionUID = 597734329161281398L;
@@ -58,44 +62,4 @@ public static List
- * 统计接口的共用属性类
+ * 统计接口的共用属性类.
* Created by Binary Wang on 2016/8/25.
*
*
- * @author binarywang(Binary Wang)
+ * @author Binary Wang
*/
+@Data
public abstract class WxDataCubeBaseResult implements Serializable {
private static final long serialVersionUID = 8780389911053297600L;
protected static final JsonParser JSON_PARSER = new JsonParser();
/**
- * ref_date
+ * ref_date.
* 数据的日期,需在begin_date和end_date之间
*/
@SerializedName("ref_date")
@@ -30,12 +32,4 @@ public String toString() {
return ToStringUtils.toSimpleString(this);
}
- public String getRefDate() {
- return this.refDate;
- }
-
- public void setRefDate(String refDate) {
- this.refDate = refDate;
- }
-
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java
index fce9fc2018..b151c0089f 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java
@@ -1,18 +1,22 @@
package me.chanjar.weixin.mp.bean.datacube;
-import com.google.gson.JsonParser;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
import java.util.List;
/**
* 接口分析数据接口返回结果对象
+ *
* 请使用
- * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_TEXT}
- * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_IMAGE}
- * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VOICE}
- * {@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_NEWS}
- * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MPNEWS}
- * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_WXCARD}
+ * {@link WxConsts.KefuMsgType#TEXT}
+ * {@link WxConsts.KefuMsgType#IMAGE}
+ * {@link WxConsts.KefuMsgType#VOICE}
+ * {@link WxConsts.KefuMsgType#MUSIC}
+ * {@link WxConsts.KefuMsgType#VIDEO}
+ * {@link WxConsts.KefuMsgType#NEWS}
+ * {@link WxConsts.KefuMsgType#MPNEWS}
+ * {@link WxConsts.KefuMsgType#WXCARD}
*
*
- * @param msgType
*/
public void setMsgType(String msgType) {
this.msgType = msgType;
}
- public String getMpNewsMediaId() {
- return this.mpNewsMediaId;
- }
-
- public void setMpNewsMediaId(String mpNewsMediaId) {
- this.mpNewsMediaId = mpNewsMediaId;
- }
-
- public String getContent() {
- return this.content;
- }
-
- public void setContent(String content) {
- this.content = content;
- }
-
- public String getMediaId() {
- return this.mediaId;
- }
-
- public void setMediaId(String mediaId) {
- this.mediaId = mediaId;
- }
-
- public String getThumbMediaId() {
- return this.thumbMediaId;
- }
-
- public void setThumbMediaId(String thumbMediaId) {
- this.thumbMediaId = thumbMediaId;
- }
-
- public String getTitle() {
- return this.title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getMusicUrl() {
- return this.musicUrl;
- }
-
- public void setMusicUrl(String musicUrl) {
- this.musicUrl = musicUrl;
- }
-
- public String getHqMusicUrl() {
- return this.hqMusicUrl;
- }
-
- public void setHqMusicUrl(String hqMusicUrl) {
- this.hqMusicUrl = hqMusicUrl;
- }
-
- public String getCardId() {
- return this.cardId;
- }
-
- public void setCardId(String cardId) {
- this.cardId = cardId;
- }
-
- public List
* Created by Binary Wang on 2016-11-25.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
public class WxMpGetSelfMenuInfoResult implements Serializable {
private static final long serialVersionUID = -5612495636936835166L;
@@ -30,19 +33,4 @@ public String toString() {
return ToStringUtils.toSimpleString(this);
}
- public WxMpSelfMenuInfo getSelfMenuInfo() {
- return selfMenuInfo;
- }
-
- public void setSelfMenuInfo(WxMpSelfMenuInfo selfMenuInfo) {
- this.selfMenuInfo = selfMenuInfo;
- }
-
- public Integer getIsMenuOpen() {
- return isMenuOpen;
- }
-
- public void setIsMenuOpen(Integer isMenuOpen) {
- this.isMenuOpen = isMenuOpen;
- }
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java
index 5e93d7e0d6..1847be3f08 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java
@@ -1,6 +1,7 @@
package me.chanjar.weixin.mp.bean.menu;
import com.google.gson.annotations.SerializedName;
+import lombok.Data;
import me.chanjar.weixin.common.bean.menu.WxMenuButton;
import me.chanjar.weixin.common.bean.menu.WxMenuRule;
import me.chanjar.weixin.common.util.ToStringUtils;
@@ -13,9 +14,11 @@
*
* 公众号专用的菜单类,可能包含个性化菜单
* Created by Binary Wang on 2017-1-17.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
public class WxMpMenu implements Serializable {
private static final long serialVersionUID = -5794350513426702252L;
@@ -29,22 +32,6 @@ public static WxMpMenu fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxMpMenu.class);
}
- public WxMpConditionalMenu getMenu() {
- return menu;
- }
-
- public void setMenu(WxMpConditionalMenu menu) {
- this.menu = menu;
- }
-
- public List
* Created by Binary Wang on 2016-11-25.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
public class WxMpSelfMenuInfo implements Serializable {
private static final long serialVersionUID = -81203094124202901L;
@@ -27,15 +30,10 @@ public String toString() {
return ToStringUtils.toSimpleString(this);
}
- public List
* 菜单的类型,公众平台官网上能够设置的菜单类型有view(跳转网页)、text(返回文本,下同)、img、photo、video、voice。
@@ -92,63 +90,10 @@ public String toString() {
return ToStringUtils.toSimpleString(this);
}
- public SubButtons getSubButtons() {
- return subButtons;
- }
+ @Data
+ public static class SubButtons implements Serializable {
+ private static final long serialVersionUID = 1763350658575521079L;
- public void setSubButtons(SubButtons subButtons) {
- this.subButtons = subButtons;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getKey() {
- return key;
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public NewsInfo getNewsInfo() {
- return newsInfo;
- }
-
- public void setNewsInfo(NewsInfo newsInfo) {
- this.newsInfo = newsInfo;
- }
-
- public static class SubButtons {
@SerializedName("list")
private List
*/
+@Data
public class WxMpCurrentAutoReplyInfo implements Serializable {
private static final long serialVersionUID = 8294705001262751638L;
@@ -47,46 +49,7 @@ public static WxMpCurrentAutoReplyInfo fromJson(String json) {
@SerializedName("keyword_autoreply_info")
private KeywordAutoReplyInfo keywordAutoReplyInfo;
- public Boolean getAddFriendReplyOpen() {
- return this.isAddFriendReplyOpen;
- }
-
- public void setAddFriendReplyOpen(Boolean addFriendReplyOpen) {
- isAddFriendReplyOpen = addFriendReplyOpen;
- }
-
- public Boolean getAutoReplyOpen() {
- return this.isAutoReplyOpen;
- }
-
- public void setAutoReplyOpen(Boolean autoReplyOpen) {
- isAutoReplyOpen = autoReplyOpen;
- }
-
- public AutoReplyInfo getAddFriendAutoReplyInfo() {
- return this.addFriendAutoReplyInfo;
- }
-
- public void setAddFriendAutoReplyInfo(AutoReplyInfo addFriendAutoReplyInfo) {
- this.addFriendAutoReplyInfo = addFriendAutoReplyInfo;
- }
-
- public AutoReplyInfo getMessageDefaultAutoReplyInfo() {
- return this.messageDefaultAutoReplyInfo;
- }
-
- public void setMessageDefaultAutoReplyInfo(AutoReplyInfo messageDefaultAutoReplyInfo) {
- this.messageDefaultAutoReplyInfo = messageDefaultAutoReplyInfo;
- }
-
- public KeywordAutoReplyInfo getKeywordAutoReplyInfo() {
- return this.keywordAutoReplyInfo;
- }
-
- public void setKeywordAutoReplyInfo(KeywordAutoReplyInfo keywordAutoReplyInfo) {
- this.keywordAutoReplyInfo = keywordAutoReplyInfo;
- }
-
+ @Data
public static class AutoReplyRule implements Serializable {
private static final long serialVersionUID = -6415971838145909046L;
@@ -111,47 +74,9 @@ public String toString() {
@SerializedName("reply_list_info")
private List
* 当接受用户消息时,可能会获得以下值:
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LOCATION}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LINK}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_EVENT}
+ * {@link WxConsts.XmlMsgType#TEXT}
+ * {@link WxConsts.XmlMsgType#IMAGE}
+ * {@link WxConsts.XmlMsgType#VOICE}
+ * {@link WxConsts.XmlMsgType#VIDEO}
+ * {@link WxConsts.XmlMsgType#LOCATION}
+ * {@link WxConsts.XmlMsgType#LINK}
+ * {@link WxConsts.XmlMsgType#EVENT}
*
*/
public String getMsgType() {
@@ -658,405 +484,19 @@ public String getMsgType() {
/**
*
* 当发送消息的时候使用:
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_NEWS}
- * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_MUSIC}
+ * {@link WxConsts.XmlMsgType#TEXT}
+ * {@link WxConsts.XmlMsgType#IMAGE}
+ * {@link WxConsts.XmlMsgType#VOICE}
+ * {@link WxConsts.XmlMsgType#VIDEO}
+ * {@link WxConsts.XmlMsgType#NEWS}
+ * {@link WxConsts.XmlMsgType#MUSIC}
*
*
- * @param msgType
*/
public void setMsgType(String msgType) {
this.msgType = msgType;
}
- public String getContent() {
- return this.content;
- }
-
- public void setContent(String content) {
- this.content = content;
- }
-
- public Long getMsgId() {
- return this.msgId;
- }
-
- public void setMsgId(Long msgId) {
- this.msgId = msgId;
- }
-
- public String getPicUrl() {
- return this.picUrl;
- }
-
- public void setPicUrl(String picUrl) {
- this.picUrl = picUrl;
- }
-
- public String getMediaId() {
- return this.mediaId;
- }
-
- public void setMediaId(String mediaId) {
- this.mediaId = mediaId;
- }
-
- public String getFormat() {
- return this.format;
- }
-
- public void setFormat(String format) {
- this.format = format;
- }
-
- public String getThumbMediaId() {
- return this.thumbMediaId;
- }
-
- public void setThumbMediaId(String thumbMediaId) {
- this.thumbMediaId = thumbMediaId;
- }
-
- public Double getLocationX() {
- return this.locationX;
- }
-
- public void setLocationX(Double locationX) {
- this.locationX = locationX;
- }
-
- public Double getLocationY() {
- return this.locationY;
- }
-
- public void setLocationY(Double locationY) {
- this.locationY = locationY;
- }
-
- public Double getScale() {
- return this.scale;
- }
-
- public void setScale(Double scale) {
- this.scale = scale;
- }
-
- public String getLabel() {
- return this.label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- public String getTitle() {
- return this.title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getUrl() {
- return this.url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public String getEvent() {
- return this.event;
- }
-
- public void setEvent(String event) {
- this.event = event;
- }
-
- public String getEventKey() {
- return this.eventKey;
- }
-
- public void setEventKey(String eventKey) {
- this.eventKey = eventKey;
- }
-
- public String getTicket() {
- return this.ticket;
- }
-
- public void setTicket(String ticket) {
- this.ticket = ticket;
- }
-
- public Double getLatitude() {
- return this.latitude;
- }
-
- public void setLatitude(Double latitude) {
- this.latitude = latitude;
- }
-
- public Double getLongitude() {
- return this.longitude;
- }
-
- public void setLongitude(Double longitude) {
- this.longitude = longitude;
- }
-
- public Double getPrecision() {
- return this.precision;
- }
-
- public void setPrecision(Double precision) {
- this.precision = precision;
- }
-
- public String getRecognition() {
- return this.recognition;
- }
-
- public void setRecognition(String recognition) {
- this.recognition = recognition;
- }
-
- public String getFromUser() {
- return this.fromUser;
- }
-
- public void setFromUser(String fromUser) {
- this.fromUser = fromUser;
- }
-
- public String getStatus() {
- return this.status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public Integer getTotalCount() {
- return this.totalCount;
- }
-
- public void setTotalCount(Integer totalCount) {
- this.totalCount = totalCount;
- }
-
- public Integer getFilterCount() {
- return this.filterCount;
- }
-
- public void setFilterCount(Integer filterCount) {
- this.filterCount = filterCount;
- }
-
- public Integer getSentCount() {
- return this.sentCount;
- }
-
- public void setSentCount(Integer sentCount) {
- this.sentCount = sentCount;
- }
-
- public Integer getErrorCount() {
- return this.errorCount;
- }
-
- public void setErrorCount(Integer errorCount) {
- this.errorCount = errorCount;
- }
-
- public String getCardId() {
- return this.cardId;
- }
-
- public void setCardId(String cardId) {
- this.cardId = cardId;
- }
-
- public String getFriendUserName() {
- return this.friendUserName;
- }
-
- public void setFriendUserName(String friendUserName) {
- this.friendUserName = friendUserName;
- }
-
- public Integer getIsGiveByFriend() {
- return this.isGiveByFriend;
- }
-
- public void setIsGiveByFriend(Integer isGiveByFriend) {
- this.isGiveByFriend = isGiveByFriend;
- }
-
- public String getUserCardCode() {
- return this.userCardCode;
- }
-
- public void setUserCardCode(String userCardCode) {
- this.userCardCode = userCardCode;
- }
-
- public String getOldUserCardCode() {
- return this.oldUserCardCode;
- }
-
- public void setOldUserCardCode(String oldUserCardCode) {
- this.oldUserCardCode = oldUserCardCode;
- }
-
- public Integer getOuterId() {
- return this.outerId;
- }
-
- public void setOuterId(Integer outerId) {
- this.outerId = outerId;
- }
-
- public ScanCodeInfo getScanCodeInfo() {
- return this.scanCodeInfo;
- }
-
- public void setScanCodeInfo(ScanCodeInfo scanCodeInfo) {
- this.scanCodeInfo = scanCodeInfo;
- }
-
- public SendPicsInfo getSendPicsInfo() {
- return this.sendPicsInfo;
- }
-
- public void setSendPicsInfo(SendPicsInfo sendPicsInfo) {
- this.sendPicsInfo = sendPicsInfo;
- }
-
- public SendLocationInfo getSendLocationInfo() {
- return this.sendLocationInfo;
- }
-
- public void setSendLocationInfo(
- SendLocationInfo sendLocationInfo) {
- this.sendLocationInfo = sendLocationInfo;
- }
-
- public Long getMenuId() {
- return this.menuId;
- }
-
- public void setMenuId(Long menuId) {
- this.menuId = menuId;
- }
-
- public String getKfAccount() {
- return this.kfAccount;
- }
-
- public void setKfAccount(String kfAccount) {
- this.kfAccount = kfAccount;
- }
-
- public String getToKfAccount() {
- return this.toKfAccount;
- }
-
- public void setToKfAccount(String toKfAccount) {
- this.toKfAccount = toKfAccount;
- }
-
- public String getFromKfAccount() {
- return this.fromKfAccount;
- }
-
- public void setFromKfAccount(String fromKfAccount) {
- this.fromKfAccount = fromKfAccount;
- }
-
- public String getIsRestoreMemberCard() {
- return isRestoreMemberCard;
- }
-
- public void setIsRestoreMemberCard(String isRestoreMemberCard) {
- this.isRestoreMemberCard = isRestoreMemberCard;
- }
-
- public String getOuterStr() {
- return outerStr;
- }
-
- public void setOuterStr(String outerStr) {
- this.outerStr = outerStr;
- }
-
- public String getIsReturnBack() {
- return isReturnBack;
- }
-
- public void setIsReturnBack(String isReturnBack) {
- this.isReturnBack = isReturnBack;
- }
-
- public String getIsChatRoom() {
- return isChatRoom;
- }
-
- public void setIsChatRoom(String isChatRoom) {
- this.isChatRoom = isChatRoom;
- }
-
- public String getConsumeSource() {
- return this.consumeSource;
- }
-
- public void setConsumeSource(String consumeSource) {
- this.consumeSource = consumeSource;
- }
-
- public String getLocationName() {
- return this.locationName;
- }
-
- public void setLocationName(String locationName) {
- this.locationName = locationName;
- }
-
- public String getStaffOpenId() {
- return this.staffOpenId;
- }
-
- public void setStaffOpenId(String staffOpenId) {
- this.staffOpenId = staffOpenId;
- }
-
- public String getVerifyCode() {
- return this.verifyCode;
- }
-
- public void setVerifyCode(String verifyCode) {
- this.verifyCode = verifyCode;
- }
-
- public String getRemarkAmount() {
- return this.remarkAmount;
- }
-
- public void setRemarkAmount(String remarkAmount) {
- this.remarkAmount = remarkAmount;
- }
-
@Override
public String toString() {
return ToStringUtils.toSimpleString(this);
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java
index c18508b527..dbb0ab90f9 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java
@@ -2,10 +2,14 @@
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.util.xml.XStreamMediaIdConverter;
@XStreamAlias("xml")
+@Data
+@EqualsAndHashCode(callSuper = true)
public class WxMpXmlOutImageMessage extends WxMpXmlOutMessage {
private static final long serialVersionUID = -2684778597067990723L;
@@ -14,15 +18,7 @@ public class WxMpXmlOutImageMessage extends WxMpXmlOutMessage {
private String mediaId;
public WxMpXmlOutImageMessage() {
- this.msgType = WxConsts.XML_MSG_IMAGE;
- }
-
- public String getMediaId() {
- return this.mediaId;
- }
-
- public void setMediaId(String mediaId) {
- this.mediaId = mediaId;
+ this.msgType = WxConsts.XmlMsgType.IMAGE;
}
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMessage.java
index c84cc665b9..b1940fc487 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMessage.java
@@ -2,6 +2,7 @@
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;
+import lombok.Data;
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.builder.outxml.*;
@@ -11,6 +12,7 @@
import java.io.Serializable;
@XStreamAlias("xml")
+@Data
public abstract class WxMpXmlOutMessage implements Serializable {
private static final long serialVersionUID = -381382011286216263L;
@@ -78,38 +80,6 @@ public static TransferCustomerServiceBuilder TRANSFER_CUSTOMER_SERVICE() {
return new TransferCustomerServiceBuilder();
}
- public String getToUserName() {
- return this.toUserName;
- }
-
- public void setToUserName(String toUserName) {
- this.toUserName = toUserName;
- }
-
- public String getFromUserName() {
- return this.fromUserName;
- }
-
- public void setFromUserName(String fromUserName) {
- this.fromUserName = fromUserName;
- }
-
- public Long getCreateTime() {
- return this.createTime;
- }
-
- public void setCreateTime(Long createTime) {
- this.createTime = createTime;
- }
-
- public String getMsgType() {
- return this.msgType;
- }
-
- public void setMsgType(String msgType) {
- this.msgType = msgType;
- }
-
@SuppressWarnings("unchecked")
public String toXml() {
return XStreamTransformer.toXml((Class
* 微信公众号事件的相关常量
* Created by Binary Wang on 2017-5-10.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
public class WxMpEventConstants {
/**
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialVoiceAndImageDownloadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialVoiceAndImageDownloadRequestExecutor.java
index 09cb70d0f5..8a4f7462f7 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialVoiceAndImageDownloadRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialVoiceAndImageDownloadRequestExecutor.java
@@ -9,7 +9,8 @@
import java.io.File;
import java.io.InputStream;
-public abstract class MaterialVoiceAndImageDownloadRequestExecutor
* Created by Binary Wang on 2016-10-14.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
@Guice(modules = ApiTestModule.class)
public class WxMpTemplateMsgServiceImplTest {
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImplTest.java
index cc8676d477..1a96ba510a 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImplTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImplTest.java
@@ -12,8 +12,9 @@
import java.util.List;
/**
- * @author binarywang(Binary Wang)
- * Created by Binary Wang on 2016/9/2.
+ * Created by Binary Wang on 2016/9/2.
+ *
+ * @author Binary Wang
*/
@Test
@Guice(modules = ApiTestModule.class)
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java
index 2a9421a499..030da968e9 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java
@@ -6,7 +6,6 @@
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpService;
-import me.chanjar.weixin.mp.api.impl.WxMpServiceApacheHttpClientImpl;
import me.chanjar.weixin.mp.api.impl.WxMpServiceOkHttpImpl;
import java.io.IOException;
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessageTest.java
index c25c502495..bfeb84c119 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessageTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessageTest.java
@@ -11,7 +11,7 @@ public class WxMpKefuMessageTest {
public void testTextReply() {
WxMpKefuMessage reply = new WxMpKefuMessage();
reply.setToUser("OPENID");
- reply.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
+ reply.setMsgType(WxConsts.KefuMsgType.TEXT);
reply.setContent("sfsfdsdf");
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}");
}
@@ -24,7 +24,7 @@ public void testTextBuild() {
public void testImageReply() {
WxMpKefuMessage reply = new WxMpKefuMessage();
reply.setToUser("OPENID");
- reply.setMsgType(WxConsts.CUSTOM_MSG_IMAGE);
+ reply.setMsgType(WxConsts.KefuMsgType.IMAGE);
reply.setMediaId("MEDIA_ID");
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}");
}
@@ -37,7 +37,7 @@ public void testImageBuild() {
public void testVoiceReply() {
WxMpKefuMessage reply = new WxMpKefuMessage();
reply.setToUser("OPENID");
- reply.setMsgType(WxConsts.CUSTOM_MSG_VOICE);
+ reply.setMsgType(WxConsts.KefuMsgType.VOICE);
reply.setMediaId("MEDIA_ID");
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}");
}
@@ -50,7 +50,7 @@ public void testVoiceBuild() {
public void testVideoReply() {
WxMpKefuMessage reply = new WxMpKefuMessage();
reply.setToUser("OPENID");
- reply.setMsgType(WxConsts.CUSTOM_MSG_VIDEO);
+ reply.setMsgType(WxConsts.KefuMsgType.VIDEO);
reply.setMediaId("MEDIA_ID");
reply.setThumbMediaId("MEDIA_ID");
reply.setTitle("TITLE");
@@ -66,7 +66,7 @@ public void testVideoBuild() {
public void testMusicReply() {
WxMpKefuMessage reply = new WxMpKefuMessage();
reply.setToUser("OPENID");
- reply.setMsgType(WxConsts.CUSTOM_MSG_MUSIC);
+ reply.setMsgType(WxConsts.KefuMsgType.MUSIC);
reply.setThumbMediaId("MEDIA_ID");
reply.setDescription("DESCRIPTION");
reply.setTitle("TITLE");
@@ -90,7 +90,7 @@ public void testMusicBuild() {
public void testNewsReply() {
WxMpKefuMessage reply = new WxMpKefuMessage();
reply.setToUser("OPENID");
- reply.setMsgType(WxConsts.CUSTOM_MSG_NEWS);
+ reply.setMsgType(WxConsts.KefuMsgType.NEWS);
WxArticle article1 = new WxArticle();
article1.setUrl("URL");
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java
index 9c2bbf56ac..2224329b26 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java
@@ -58,7 +58,7 @@ public void testFromXml() {
assertEquals(wxMessage.getToUser(), "toUser");
assertEquals(wxMessage.getFromUser(), "fromUser");
assertEquals(wxMessage.getCreateTime(), new Long(1348831860L));
- assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT);
+ assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT);
assertEquals(wxMessage.getContent(), "this is a test");
assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L));
assertEquals(wxMessage.getPicUrl(), "this is a url");
@@ -86,7 +86,7 @@ public void testFromXml() {
assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113");
assertEquals(wxMessage.getSendLocationInfo().getScale(), "15");
assertEquals(wxMessage.getSendLocationInfo().getLabel(), " 广州市海珠区客村艺苑路 106号");
- assertEquals(wxMessage.getSendLocationInfo().getPoiname(), "wo de poi");
+ assertEquals(wxMessage.getSendLocationInfo().getPoiName(), "wo de poi");
}
public void testFromXml2() {
@@ -139,7 +139,7 @@ public void testFromXml2() {
assertEquals(wxMessage.getToUser(), "toUser");
assertEquals(wxMessage.getFromUser(), "fromUser");
assertEquals(wxMessage.getCreateTime(), new Long(1348831860L));
- assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT);
+ assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT);
assertEquals(wxMessage.getContent(), "this is a test");
assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L));
assertEquals(wxMessage.getPicUrl(), "this is a url");
@@ -167,7 +167,7 @@ public void testFromXml2() {
assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113");
assertEquals(wxMessage.getSendLocationInfo().getScale(), "15");
assertEquals(wxMessage.getSendLocationInfo().getLabel(), " 广州市海珠区客村艺苑路 106号");
- assertEquals(wxMessage.getSendLocationInfo().getPoiname(), "wo de poi");
+ assertEquals(wxMessage.getSendLocationInfo().getPoiName(), "wo de poi");
}
}
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessageTest.java
index f75e6321e6..592a6a50ed 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessageTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessageTest.java
@@ -13,7 +13,7 @@ public void test() {
m.setHqMusicUrl("hQMusicUrl");
m.setMusicUrl("musicUrl");
m.setThumbMediaId("thumbMediaId");
- m.setCreateTime(1122l);
+ m.setCreateTime(1122L);
m.setFromUserName("fromUser");
m.setToUserName("toUser");
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfoTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfoTest.java
index da2cddff40..dbed60bac9 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfoTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfoTest.java
@@ -145,8 +145,8 @@ public void testFromJson() throws Exception {
WxMpCurrentAutoReplyInfo autoReplyInfo = WxMpCurrentAutoReplyInfo.fromJson(json);
assertNotNull(autoReplyInfo);
- assertTrue(autoReplyInfo.getAddFriendReplyOpen());
- assertTrue(autoReplyInfo.getAutoReplyOpen());
+ assertTrue(autoReplyInfo.getIsAddFriendReplyOpen());
+ assertTrue(autoReplyInfo.getIsAutoReplyOpen());
assertNotNull(autoReplyInfo.getAddFriendAutoReplyInfo());
assertNotNull(autoReplyInfo.getMessageDefaultAutoReplyInfo());
assertTrue(autoReplyInfo.getKeywordAutoReplyInfo().getList().size() > 0);
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessageTest.java
index ac415ff454..3bb804d5c8 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessageTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessageTest.java
@@ -7,8 +7,9 @@
/**
*
* Created by Binary Wang on 2017-3-30.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
public class WxMpTemplateMessageTest {
@Test
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoImageHandler.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoImageHandler.java
index 2390071b6c..5578f637be 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoImageHandler.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoImageHandler.java
@@ -19,7 +19,7 @@ public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map
* 微信支付接口请求数据封装对象
@@ -8,6 +11,8 @@
*
* @author Binary Wang
*/
+@Data
+@NoArgsConstructor
public class WxPayApiData {
/**
* 接口请求地址
@@ -42,38 +47,6 @@ public WxPayApiData(String url, String requestData, String responseData, String
this.exceptionMsg = exceptionMsg;
}
- public String getUrl() {
- return this.url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public String getRequestData() {
- return this.requestData;
- }
-
- public void setRequestData(String requestData) {
- this.requestData = requestData;
- }
-
- public String getResponseData() {
- return this.responseData;
- }
-
- public void setResponseData(String responseData) {
- this.responseData = responseData;
- }
-
- public String getExceptionMsg() {
- return this.exceptionMsg;
- }
-
- public void setExceptionMsg(String exceptionMsg) {
- this.exceptionMsg = exceptionMsg;
- }
-
@Override
public String toString() {
if (this.exceptionMsg != null) {
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryRequest.java
index 3d83d0a6c6..54d16bd96a 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryRequest.java
@@ -2,6 +2,7 @@
import com.github.binarywang.wxpay.bean.request.WxPayBaseRequest;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
import me.chanjar.weixin.common.annotation.Required;
/**
@@ -12,8 +13,13 @@
*
* @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
-public class WxPayCouponInfoQueryRequest extends WxPayBaseRequest {
+public class WxPayCouponInfoQueryRequest extends WxPayBaseRequest {
/**
*
* 字段名:代金券id
@@ -108,173 +114,10 @@ public class WxPayCouponInfoQueryRequest extends WxPayBaseRequest {
@XStreamAlias("type")
private String type;
- private WxPayCouponInfoQueryRequest(Builder builder) {
- setAppid(builder.appid);
- setMchId(builder.mchId);
- setSubAppId(builder.subAppId);
- setSubMchId(builder.subMchId);
- setNonceStr(builder.nonceStr);
- setSign(builder.sign);
- setCouponId(builder.couponId);
- setStockId(builder.stockId);
- setOpenid(builder.openid);
- setOpUserId(builder.opUserId);
- setDeviceInfo(builder.deviceInfo);
- setVersion(builder.version);
- setType(builder.type);
- }
-
- public static Builder newBuilder() {
- return new Builder();
- }
-
- public String getCouponId() {
- return this.couponId;
- }
-
- public void setCouponId(String couponId) {
- this.couponId = couponId;
- }
-
- public String getStockId() {
- return this.stockId;
- }
-
- public void setStockId(String stockId) {
- this.stockId = stockId;
- }
-
- public String getOpenid() {
- return this.openid;
- }
-
- public void setOpenid(String openid) {
- this.openid = openid;
- }
-
- public String getOpUserId() {
- return this.opUserId;
- }
-
- public void setOpUserId(String opUserId) {
- this.opUserId = opUserId;
- }
-
- public String getDeviceInfo() {
- return this.deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getVersion() {
- return this.version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public String getType() {
- return this.type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
@Override
protected void checkConstraints() {
//do nothing
}
-
- public static final class Builder {
- private String appid;
- private String mchId;
- private String subAppId;
- private String subMchId;
- private String nonceStr;
- private String sign;
- private String couponId;
- private String stockId;
- private String openid;
- private String opUserId;
- private String deviceInfo;
- private String version;
- private String type;
-
- private Builder() {
- }
-
- public Builder appid(String appid) {
- this.appid = appid;
- return this;
- }
-
- public Builder mchId(String mchId) {
- this.mchId = mchId;
- return this;
- }
-
- public Builder subAppId(String subAppId) {
- this.subAppId = subAppId;
- return this;
- }
-
- public Builder subMchId(String subMchId) {
- this.subMchId = subMchId;
- return this;
- }
-
- public Builder nonceStr(String nonceStr) {
- this.nonceStr = nonceStr;
- return this;
- }
-
- public Builder sign(String sign) {
- this.sign = sign;
- return this;
- }
-
- public Builder couponId(String couponId) {
- this.couponId = couponId;
- return this;
- }
-
- public Builder stockId(String stockId) {
- this.stockId = stockId;
- return this;
- }
-
- public Builder openid(String openid) {
- this.openid = openid;
- return this;
- }
-
- public Builder opUserId(String opUserId) {
- this.opUserId = opUserId;
- return this;
- }
-
- public Builder deviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- return this;
- }
-
- public Builder version(String version) {
- this.version = version;
- return this;
- }
-
- public Builder type(String type) {
- this.type = type;
- return this;
- }
-
- public WxPayCouponInfoQueryRequest build() {
- return new WxPayCouponInfoQueryRequest(this);
- }
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java
index bec1c9e10a..f7d9138392 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java
@@ -2,6 +2,9 @@
import com.github.binarywang.wxpay.bean.result.WxPayBaseResult;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
/**
*
@@ -11,11 +14,14 @@
*
* @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/**
*
- * 字段名:设备号
+ * 字段名:设备号.
* 变量名:device_info
* 是否必填:否
* 示例值:123456sb
@@ -28,7 +34,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/**
*
- * 字段名:批次ID
+ * 字段名:批次ID.
* 变量名:coupon_stock_id
* 是否必填:是
* 示例值:1567
@@ -41,7 +47,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/**
*
- * 字段名:代金券id
+ * 字段名:代金券id.
* 变量名:coupon_id
* 是否必填:是
* 示例值:4242
@@ -54,7 +60,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/**
*
- * 字段名:代金券面额
+ * 字段名:代金券面额.
* 变量名:coupon_value
* 是否必填:是
* 示例值:4
@@ -67,7 +73,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/**
*
- * 字段名:代金券使用门槛
+ * 字段名:代金券使用门槛.
* 变量名:coupon_mininum
* 是否必填:是
* 示例值:10
@@ -80,7 +86,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/**
*
- * 字段名:代金券名称
+ * 字段名:代金券名称.
* 变量名:coupon_name
* 是否必填:是
* 示例值:测试代金券
@@ -93,20 +99,20 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/**
*
- * 字段名:代金券状态
+ * 字段名:代金券状态.
* 变量名:coupon_state
* 是否必填:是
* 示例值:SENDED
- * 类型:int
+ * 类型:String
* 说明:代金券状态:SENDED-可用,USED-已实扣,EXPIRED-已过期
*
*/
@XStreamAlias("coupon_state")
- private Integer couponState;
+ private String couponState;
/**
*
- * 字段名:代金券描述
+ * 字段名:代金券描述.
* 变量名:coupon_desc
* 是否必填:是
* 示例值:微信支付-代金券
@@ -119,7 +125,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/**
*
- * 字段名:实际优惠金额
+ * 字段名:实际优惠金额.
* 变量名:coupon_use_value
* 是否必填:是
* 示例值:0
@@ -132,7 +138,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/**
*
- * 字段名:优惠剩余可用额
+ * 字段名:优惠剩余可用额.
* 变量名:coupon_remain_value
* 是否必填:是
* 示例值:4
@@ -145,7 +151,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/**
*
- * 字段名:生效开始时间
+ * 字段名:生效开始时间.
* 变量名:begin_time
* 是否必填:是
* 示例值:1943787483
@@ -158,7 +164,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/**
*
- * 字段名:生效结束时间
+ * 字段名:生效结束时间.
* 变量名:end_time
* 是否必填:是
* 示例值:1943787484
@@ -171,7 +177,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/**
*
- * 字段名:发放时间
+ * 字段名:发放时间.
* 变量名:send_time
* 是否必填:是
* 示例值:1943787420
@@ -184,7 +190,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/**
*
- * 字段名:消耗方商户id
+ * 字段名:消耗方商户id.
* 变量名:consumer_mch_id
* 是否必填:否
* 示例值:10000098
@@ -197,7 +203,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/**
*
- * 字段名:发放来源
+ * 字段名:发放来源.
* 变量名:send_source
* 是否必填:是
* 示例值:FULL_SEND
@@ -210,7 +216,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/**
*
- * 字段名:是否允许部分使用
+ * 字段名:是否允许部分使用.
* 变量名:is_partial_use
* 是否必填:否
* 示例值:1
@@ -221,131 +227,4 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
@XStreamAlias("is_partial_use")
private String isPartialUse;
- public String getDeviceInfo() {
- return this.deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getCouponStockId() {
- return this.couponStockId;
- }
-
- public void setCouponStockId(String couponStockId) {
- this.couponStockId = couponStockId;
- }
-
- public String getCouponId() {
- return this.couponId;
- }
-
- public void setCouponId(String couponId) {
- this.couponId = couponId;
- }
-
- public Integer getCouponValue() {
- return this.couponValue;
- }
-
- public void setCouponValue(Integer couponValue) {
- this.couponValue = couponValue;
- }
-
- public Integer getCouponMininum() {
- return this.couponMininum;
- }
-
- public void setCouponMininum(Integer couponMininum) {
- this.couponMininum = couponMininum;
- }
-
- public String getCouponName() {
- return this.couponName;
- }
-
- public void setCouponName(String couponName) {
- this.couponName = couponName;
- }
-
- public Integer getCouponState() {
- return this.couponState;
- }
-
- public void setCouponState(Integer couponState) {
- this.couponState = couponState;
- }
-
- public String getCouponDesc() {
- return this.couponDesc;
- }
-
- public void setCouponDesc(String couponDesc) {
- this.couponDesc = couponDesc;
- }
-
- public Integer getCouponUseValue() {
- return this.couponUseValue;
- }
-
- public void setCouponUseValue(Integer couponUseValue) {
- this.couponUseValue = couponUseValue;
- }
-
- public Integer getCouponRemainValue() {
- return this.couponRemainValue;
- }
-
- public void setCouponRemainValue(Integer couponRemainValue) {
- this.couponRemainValue = couponRemainValue;
- }
-
- public String getBeginTime() {
- return this.beginTime;
- }
-
- public void setBeginTime(String beginTime) {
- this.beginTime = beginTime;
- }
-
- public String getEndTime() {
- return this.endTime;
- }
-
- public void setEndTime(String endTime) {
- this.endTime = endTime;
- }
-
- public String getSendTime() {
- return this.sendTime;
- }
-
- public void setSendTime(String sendTime) {
- this.sendTime = sendTime;
- }
-
- public String getConsumerMchId() {
- return this.consumerMchId;
- }
-
- public void setConsumerMchId(String consumerMchId) {
- this.consumerMchId = consumerMchId;
- }
-
- public String getSendSource() {
- return this.sendSource;
- }
-
- public void setSendSource(String sendSource) {
- this.sendSource = sendSource;
- }
-
- public String getIsPartialUse() {
- return this.isPartialUse;
- }
-
- public void setIsPartialUse(String isPartialUse) {
- this.isPartialUse = isPartialUse;
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendRequest.java
index 9a98fd64a2..63b891d8bc 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendRequest.java
@@ -2,6 +2,7 @@
import com.github.binarywang.wxpay.bean.request.WxPayBaseRequest;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
import me.chanjar.weixin.common.annotation.Required;
/**
@@ -12,6 +13,12 @@
*
* @author Binary Wang
*/
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayCouponSendRequest extends WxPayBaseRequest {
/**
@@ -122,190 +129,8 @@ public class WxPayCouponSendRequest extends WxPayBaseRequest {
@XStreamAlias("type")
private String type;
- public WxPayCouponSendRequest() {
- }
-
- private WxPayCouponSendRequest(Builder builder) {
- setAppid(builder.appid);
- setMchId(builder.mchId);
- setSubAppId(builder.subAppId);
- setSubMchId(builder.subMchId);
- setNonceStr(builder.nonceStr);
- setSign(builder.sign);
- setCouponStockId(builder.couponStockId);
- setOpenidCount(builder.openidCount);
- setPartnerTradeNo(builder.partnerTradeNo);
- setOpenid(builder.openid);
- setOpUserId(builder.opUserId);
- setDeviceInfo(builder.deviceInfo);
- setVersion(builder.version);
- setType(builder.type);
- }
-
- public static Builder newBuilder() {
- return new Builder();
- }
-
- public String getCouponStockId() {
- return this.couponStockId;
- }
-
- public void setCouponStockId(String couponStockId) {
- this.couponStockId = couponStockId;
- }
-
- public Integer getOpenidCount() {
- return this.openidCount;
- }
-
- public void setOpenidCount(Integer openidCount) {
- this.openidCount = openidCount;
- }
-
- public String getPartnerTradeNo() {
- return this.partnerTradeNo;
- }
-
- public void setPartnerTradeNo(String partnerTradeNo) {
- this.partnerTradeNo = partnerTradeNo;
- }
-
- public String getOpenid() {
- return this.openid;
- }
-
- public void setOpenid(String openid) {
- this.openid = openid;
- }
-
- public String getOpUserId() {
- return this.opUserId;
- }
-
- public void setOpUserId(String opUserId) {
- this.opUserId = opUserId;
- }
-
- public String getDeviceInfo() {
- return this.deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getVersion() {
- return this.version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public String getType() {
- return this.type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
@Override
protected void checkConstraints() {
//do nothing
}
-
- public static final class Builder {
- private String appid;
- private String mchId;
- private String subAppId;
- private String subMchId;
- private String nonceStr;
- private String sign;
- private String couponStockId;
- private Integer openidCount;
- private String partnerTradeNo;
- private String openid;
- private String opUserId;
- private String deviceInfo;
- private String version;
- private String type;
-
- private Builder() {
- }
-
- public Builder appid(String appid) {
- this.appid = appid;
- return this;
- }
-
- public Builder mchId(String mchId) {
- this.mchId = mchId;
- return this;
- }
-
- public Builder subAppId(String subAppId) {
- this.subAppId = subAppId;
- return this;
- }
-
- public Builder subMchId(String subMchId) {
- this.subMchId = subMchId;
- return this;
- }
-
- public Builder nonceStr(String nonceStr) {
- this.nonceStr = nonceStr;
- return this;
- }
-
- public Builder sign(String sign) {
- this.sign = sign;
- return this;
- }
-
- public Builder couponStockId(String couponStockId) {
- this.couponStockId = couponStockId;
- return this;
- }
-
- public Builder openidCount(Integer openidCount) {
- this.openidCount = openidCount;
- return this;
- }
-
- public Builder partnerTradeNo(String partnerTradeNo) {
- this.partnerTradeNo = partnerTradeNo;
- return this;
- }
-
- public Builder openid(String openid) {
- this.openid = openid;
- return this;
- }
-
- public Builder opUserId(String opUserId) {
- this.opUserId = opUserId;
- return this;
- }
-
- public Builder deviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- return this;
- }
-
- public Builder version(String version) {
- this.version = version;
- return this;
- }
-
- public Builder type(String type) {
- this.type = type;
- return this;
- }
-
- public WxPayCouponSendRequest build() {
- return new WxPayCouponSendRequest(this);
- }
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendResult.java
index 1c562adae2..fe26342e7b 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendResult.java
@@ -2,6 +2,9 @@
import com.github.binarywang.wxpay.bean.result.WxPayBaseResult;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
/**
*
@@ -11,6 +14,9 @@
*
* @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxPayCouponSendResult extends WxPayBaseResult {
/**
@@ -130,75 +136,4 @@ public class WxPayCouponSendResult extends WxPayBaseResult {
@XStreamAlias("ret_msg")
private String retMsg;
- public String getDeviceInfo() {
- return this.deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getCouponStockId() {
- return this.couponStockId;
- }
-
- public void setCouponStockId(String couponStockId) {
- this.couponStockId = couponStockId;
- }
-
- public Integer getRespCount() {
- return this.respCount;
- }
-
- public void setRespCount(Integer respCount) {
- this.respCount = respCount;
- }
-
- public Integer getSuccessCount() {
- return this.successCount;
- }
-
- public void setSuccessCount(Integer successCount) {
- this.successCount = successCount;
- }
-
- public Integer getFailedCount() {
- return this.failedCount;
- }
-
- public void setFailedCount(Integer failedCount) {
- this.failedCount = failedCount;
- }
-
- public String getOpenid() {
- return this.openid;
- }
-
- public void setOpenid(String openid) {
- this.openid = openid;
- }
-
- public String getRetCode() {
- return this.retCode;
- }
-
- public void setRetCode(String retCode) {
- this.retCode = retCode;
- }
-
- public String getCouponId() {
- return this.couponId;
- }
-
- public void setCouponId(String couponId) {
- this.couponId = couponId;
- }
-
- public String getRetMsg() {
- return this.retMsg;
- }
-
- public void setRetMsg(String retMsg) {
- this.retMsg = retMsg;
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryRequest.java
index 24cec5523c..c7b812d857 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryRequest.java
@@ -2,6 +2,7 @@
import com.github.binarywang.wxpay.bean.request.WxPayBaseRequest;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
import me.chanjar.weixin.common.annotation.Required;
/**
@@ -12,6 +13,12 @@
*
* @author Binary Wang
*/
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayCouponStockQueryRequest extends WxPayBaseRequest {
/**
@@ -80,142 +87,9 @@ public class WxPayCouponStockQueryRequest extends WxPayBaseRequest {
@XStreamAlias("type")
private String type;
- private WxPayCouponStockQueryRequest(Builder builder) {
- setAppid(builder.appid);
- setMchId(builder.mchId);
- setSubAppId(builder.subAppId);
- setSubMchId(builder.subMchId);
- setNonceStr(builder.nonceStr);
- setSign(builder.sign);
- setCouponStockId(builder.couponStockId);
- setOpUserId(builder.opUserId);
- setDeviceInfo(builder.deviceInfo);
- setVersion(builder.version);
- setType(builder.type);
- }
-
- public static Builder newBuilder() {
- return new Builder();
- }
-
- public String getCouponStockId() {
- return this.couponStockId;
- }
-
- public void setCouponStockId(String couponStockId) {
- this.couponStockId = couponStockId;
- }
-
- public String getOpUserId() {
- return this.opUserId;
- }
-
- public void setOpUserId(String opUserId) {
- this.opUserId = opUserId;
- }
-
- public String getDeviceInfo() {
- return this.deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getVersion() {
- return this.version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public String getType() {
- return this.type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
@Override
protected void checkConstraints() {
//do nothing
}
- public static final class Builder {
- private String appid;
- private String mchId;
- private String subAppId;
- private String subMchId;
- private String nonceStr;
- private String sign;
- private String couponStockId;
- private String opUserId;
- private String deviceInfo;
- private String version;
- private String type;
-
- private Builder() {
- }
-
- public Builder appid(String appid) {
- this.appid = appid;
- return this;
- }
-
- public Builder mchId(String mchId) {
- this.mchId = mchId;
- return this;
- }
-
- public Builder subAppId(String subAppId) {
- this.subAppId = subAppId;
- return this;
- }
-
- public Builder subMchId(String subMchId) {
- this.subMchId = subMchId;
- return this;
- }
-
- public Builder nonceStr(String nonceStr) {
- this.nonceStr = nonceStr;
- return this;
- }
-
- public Builder sign(String sign) {
- this.sign = sign;
- return this;
- }
-
- public Builder couponStockId(String couponStockId) {
- this.couponStockId = couponStockId;
- return this;
- }
-
- public Builder opUserId(String opUserId) {
- this.opUserId = opUserId;
- return this;
- }
-
- public Builder deviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- return this;
- }
-
- public Builder version(String version) {
- this.version = version;
- return this;
- }
-
- public Builder type(String type) {
- this.type = type;
- return this;
- }
-
- public WxPayCouponStockQueryRequest build() {
- return new WxPayCouponStockQueryRequest(this);
- }
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryResult.java
index 065c3f606d..2f97618e1d 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryResult.java
@@ -2,6 +2,10 @@
import com.github.binarywang.wxpay.bean.result.WxPayBaseResult;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
/**
*
@@ -11,6 +15,10 @@
*
* @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayCouponStockQueryResult extends WxPayBaseResult {
/**
@@ -182,107 +190,4 @@ public class WxPayCouponStockQueryResult extends WxPayBaseResult {
@XStreamAlias("coupon_budget")
private Integer couponBudget;
- public String getDeviceInfo() {
- return this.deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getCouponStockId() {
- return this.couponStockId;
- }
-
- public void setCouponStockId(String couponStockId) {
- this.couponStockId = couponStockId;
- }
-
- public String getCouponName() {
- return this.couponName;
- }
-
- public void setCouponName(String couponName) {
- this.couponName = couponName;
- }
-
- public Integer getCouponValue() {
- return this.couponValue;
- }
-
- public void setCouponValue(Integer couponValue) {
- this.couponValue = couponValue;
- }
-
- public Integer getCouponMininumn() {
- return this.couponMininumn;
- }
-
- public void setCouponMininumn(Integer couponMininumn) {
- this.couponMininumn = couponMininumn;
- }
-
- public Integer getCouponStockStatus() {
- return this.couponStockStatus;
- }
-
- public void setCouponStockStatus(Integer couponStockStatus) {
- this.couponStockStatus = couponStockStatus;
- }
-
- public Integer getCouponTotal() {
- return this.couponTotal;
- }
-
- public void setCouponTotal(Integer couponTotal) {
- this.couponTotal = couponTotal;
- }
-
- public Integer getMaxQuota() {
- return this.maxQuota;
- }
-
- public void setMaxQuota(Integer maxQuota) {
- this.maxQuota = maxQuota;
- }
-
- public Integer getIsSendNum() {
- return this.isSendNum;
- }
-
- public void setIsSendNum(Integer isSendNum) {
- this.isSendNum = isSendNum;
- }
-
- public String getBeginTime() {
- return this.beginTime;
- }
-
- public void setBeginTime(String beginTime) {
- this.beginTime = beginTime;
- }
-
- public String getEndTime() {
- return this.endTime;
- }
-
- public void setEndTime(String endTime) {
- this.endTime = endTime;
- }
-
- public String getCreateTime() {
- return this.createTime;
- }
-
- public void setCreateTime(String createTime) {
- this.createTime = createTime;
- }
-
- public Integer getCouponBudget() {
- return this.couponBudget;
- }
-
- public void setCouponBudget(Integer couponBudget) {
- this.couponBudget = couponBudget;
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponse.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponse.java
index e7a7ea9099..c7adf850af 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponse.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponse.java
@@ -4,12 +4,20 @@
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import com.thoughtworks.xstream.annotations.XStreamOmitField;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
/**
* 微信支付订单和退款的异步通知共用的响应类
*/
+@Data
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayNotifyResponse {
@XStreamOmitField
@@ -24,16 +32,6 @@ public class WxPayNotifyResponse {
@XStreamAlias("return_msg")
private String returnMsg;
- public WxPayNotifyResponse() {
- super();
- }
-
- public WxPayNotifyResponse(String returnCode, String returnMsg) {
- super();
- this.returnCode = returnCode;
- this.returnMsg = returnMsg;
- }
-
public static String fail(String msg) {
WxPayNotifyResponse response = new WxPayNotifyResponse(FAIL, msg);
XStream xstream = XStreamInitializer.getInstance();
@@ -48,19 +46,4 @@ public static String success(String msg) {
return xstream.toXML(response);
}
- public String getReturnCode() {
- return returnCode;
- }
-
- public void setReturnCode(String returnCode) {
- this.returnCode = returnCode;
- }
-
- public String getReturnMsg() {
- return returnMsg;
- }
-
- public void setReturnMsg(String returnMsg) {
- this.returnMsg = returnMsg;
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyCoupon.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyCoupon.java
index cd948dfbac..80da09e6f9 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyCoupon.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyCoupon.java
@@ -1,7 +1,8 @@
package com.github.binarywang.wxpay.bean.notify;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import me.chanjar.weixin.common.util.ToStringUtils;
import java.io.Serializable;
import java.util.HashMap;
@@ -10,6 +11,8 @@
/**
* 支付异步通知代金券详细
*/
+@Data
+@NoArgsConstructor
public class WxPayOrderNotifyCoupon implements Serializable {
private static final long serialVersionUID = -4165343733538156097L;
@@ -17,30 +20,6 @@ public class WxPayOrderNotifyCoupon implements Serializable {
private String couponType;
private Integer couponFee;
- public String getCouponId() {
- return couponId;
- }
-
- public void setCouponId(String couponId) {
- this.couponId = couponId;
- }
-
- public String getCouponType() {
- return couponType;
- }
-
- public void setCouponType(String couponType) {
- this.couponType = couponType;
- }
-
- public Integer getCouponFee() {
- return couponFee;
- }
-
- public void setCouponFee(Integer couponFee) {
- this.couponFee = couponFee;
- }
-
public Map toMap(int index) {
Map map = new HashMap<>();
map.put("coupon_id_" + index, this.getCouponId());
@@ -51,6 +30,6 @@ public Map toMap(int index) {
@Override
public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
+ return ToStringUtils.toSimpleString(this);
}
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java
index 54657ac6ae..8cb94ee03e 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java
@@ -4,6 +4,9 @@
import com.github.binarywang.wxpay.converter.WxPayOrderNotifyResultConverter;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
import me.chanjar.weixin.common.util.BeanUtils;
import me.chanjar.weixin.common.util.ToStringUtils;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
@@ -18,6 +21,9 @@
* @author aimilin6688
* @since 2.5.0
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxPayOrderNotifyResult extends WxPayBaseResult implements Serializable {
private static final long serialVersionUID = 5389718115223345496L;
@@ -262,158 +268,6 @@ public static WxPayOrderNotifyResult fromXML(String xmlString) {
return result;
}
- public Integer getCouponCount() {
- return couponCount;
- }
-
- public void setCouponCount(Integer couponCount) {
- this.couponCount = couponCount;
- }
-
- public List getCouponList() {
- return couponList;
- }
-
- public void setCouponList(List couponList) {
- this.couponList = couponList;
- }
-
- public String getDeviceInfo() {
- return deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getOpenid() {
- return openid;
- }
-
- public void setOpenid(String openid) {
- this.openid = openid;
- }
-
- public String getIsSubscribe() {
- return isSubscribe;
- }
-
- public void setIsSubscribe(String isSubscribe) {
- this.isSubscribe = isSubscribe;
- }
-
- public String getTradeType() {
- return tradeType;
- }
-
- public void setTradeType(String tradeType) {
- this.tradeType = tradeType;
- }
-
- public String getBankType() {
- return bankType;
- }
-
- public void setBankType(String bankType) {
- this.bankType = bankType;
- }
-
- public Integer getTotalFee() {
- return totalFee;
- }
-
- public void setTotalFee(Integer totalFee) {
- this.totalFee = totalFee;
- }
-
- public Integer getSettlementTotalFee() {
- return settlementTotalFee;
- }
-
- public void setSettlementTotalFee(Integer settlementTotalFee) {
- this.settlementTotalFee = settlementTotalFee;
- }
-
- public String getFeeType() {
- return feeType;
- }
-
- public void setFeeType(String feeType) {
- this.feeType = feeType;
- }
-
- public Integer getCashFee() {
- return cashFee;
- }
-
- public void setCashFee(Integer cashFee) {
- this.cashFee = cashFee;
- }
-
- public String getCashFeeType() {
- return cashFeeType;
- }
-
- public void setCashFeeType(String cashFeeType) {
- this.cashFeeType = cashFeeType;
- }
-
- public Integer getCouponFee() {
- return couponFee;
- }
-
- public void setCouponFee(Integer couponFee) {
- this.couponFee = couponFee;
- }
-
- public String getTransactionId() {
- return transactionId;
- }
-
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
- }
-
- public String getOutTradeNo() {
- return outTradeNo;
- }
-
- public void setOutTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- }
-
- public String getAttach() {
- return attach;
- }
-
- public void setAttach(String attach) {
- this.attach = attach;
- }
-
- public String getTimeEnd() {
- return timeEnd;
- }
-
- public void setTimeEnd(String timeEnd) {
- this.timeEnd = timeEnd;
- }
-
- public String getSubOpenid() {
- return this.subOpenid;
- }
-
- public void setSubOpenid(String subOpenid) {
- this.subOpenid = subOpenid;
- }
-
- public String getSubIsSubscribe() {
- return this.subIsSubscribe;
- }
-
- public void setSubIsSubscribe(String subIsSubscribe) {
- this.subIsSubscribe = subIsSubscribe;
- }
-
@Override
public Map toMap() {
Map resultMap = BeanUtils.xmlBean2Map(this);
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java
index 392c10144c..7006c75215 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java
@@ -4,6 +4,10 @@
import com.github.binarywang.wxpay.exception.WxPayException;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
import me.chanjar.weixin.common.util.ToStringUtils;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
import org.apache.commons.codec.binary.Base64;
@@ -22,6 +26,10 @@
*
* @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayRefundNotifyResult extends WxPayBaseResult implements Serializable {
private static final long serialVersionUID = 4651725860079259186L;
@@ -68,6 +76,8 @@ public static WxPayRefundNotifyResult fromXML(String xmlString, String mchKey) t
/**
* 加密信息字段解密后的内容
*/
+ @Data
+ @NoArgsConstructor
@XStreamAlias("root")
public static class ReqInfo {
@Override
@@ -243,110 +253,6 @@ public String toString() {
@XStreamAlias("refund_request_source")
private String refundRequestSource;
- public String getTransactionId() {
- return transactionId;
- }
-
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
- }
-
- public String getOutTradeNo() {
- return outTradeNo;
- }
-
- public void setOutTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- }
-
- public String getRefundId() {
- return refundId;
- }
-
- public void setRefundId(String refundId) {
- this.refundId = refundId;
- }
-
- public String getOutRefundNo() {
- return outRefundNo;
- }
-
- public void setOutRefundNo(String outRefundNo) {
- this.outRefundNo = outRefundNo;
- }
-
- public Integer getTotalFee() {
- return totalFee;
- }
-
- public void setTotalFee(Integer totalFee) {
- this.totalFee = totalFee;
- }
-
- public Integer getSettlementTotalFee() {
- return settlementTotalFee;
- }
-
- public void setSettlementTotalFee(Integer settlementTotalFee) {
- this.settlementTotalFee = settlementTotalFee;
- }
-
- public Integer getRefundFee() {
- return refundFee;
- }
-
- public void setRefundFee(Integer refundFee) {
- this.refundFee = refundFee;
- }
-
- public Integer getSettlementRefundFee() {
- return settlementRefundFee;
- }
-
- public void setSettlementRefundFee(Integer settlementRefundFee) {
- this.settlementRefundFee = settlementRefundFee;
- }
-
- public String getRefundStatus() {
- return refundStatus;
- }
-
- public void setRefundStatus(String refundStatus) {
- this.refundStatus = refundStatus;
- }
-
- public String getSuccessTime() {
- return successTime;
- }
-
- public void setSuccessTime(String successTime) {
- this.successTime = successTime;
- }
-
- public String getRefundRecvAccout() {
- return refundRecvAccout;
- }
-
- public void setRefundRecvAccout(String refundRecvAccout) {
- this.refundRecvAccout = refundRecvAccout;
- }
-
- public String getRefundAccount() {
- return refundAccount;
- }
-
- public void setRefundAccount(String refundAccount) {
- this.refundAccount = refundAccount;
- }
-
- public String getRefundRequestSource() {
- return refundRequestSource;
- }
-
- public void setRefundRequestSource(String refundRequestSource) {
- this.refundRequestSource = refundRequestSource;
- }
-
public static ReqInfo fromXML(String xmlString) {
XStream xstream = XStreamInitializer.getInstance();
xstream.processAnnotations(ReqInfo.class);
@@ -354,19 +260,4 @@ public static ReqInfo fromXML(String xmlString) {
}
}
- public String getReqInfoString() {
- return reqInfoString;
- }
-
- public void setReqInfoString(String reqInfoString) {
- this.reqInfoString = reqInfoString;
- }
-
- public ReqInfo getReqInfo() {
- return reqInfo;
- }
-
- public void setReqInfo(ReqInfo reqInfo) {
- this.reqInfo = reqInfo;
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxScanPayNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxScanPayNotifyResult.java
similarity index 56%
rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxScanPayNotifyResult.java
rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxScanPayNotifyResult.java
index cdb94a9b79..6d08136d99 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxScanPayNotifyResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxScanPayNotifyResult.java
@@ -1,9 +1,16 @@
-package com.github.binarywang.wxpay.bean.result;
+package com.github.binarywang.wxpay.bean.notify;
+import com.github.binarywang.wxpay.bean.result.WxPayBaseResult;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
import java.io.Serializable;
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
public class WxScanPayNotifyResult extends WxPayBaseResult implements Serializable {
private static final long serialVersionUID = 3381324564266118986L;
@@ -13,12 +20,4 @@ public class WxScanPayNotifyResult extends WxPayBaseResult implements Serializab
@XStreamAlias("prepay_id")
private String prepayId;
- public String getPrepayId() {
- return prepayId;
- }
-
- public void setPrepayId(String prepayId) {
- this.prepayId = prepayId;
- }
-
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayAppOrderResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayAppOrderResult.java
index 6688d602c9..9e405aa0f9 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayAppOrderResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayAppOrderResult.java
@@ -1,5 +1,8 @@
package com.github.binarywang.wxpay.bean.order;
+import lombok.Builder;
+import lombok.Data;
+
/**
*
* APP支付调用统一下单接口后的组装所需参数的实现类
@@ -9,6 +12,8 @@
*
* @author Binary Wang
*/
+@Data
+@Builder
public class WxPayAppOrderResult {
private String sign;
private String prepayId;
@@ -17,129 +22,4 @@ public class WxPayAppOrderResult {
private String packageValue;
private String timeStamp;
private String nonceStr;
-
- public WxPayAppOrderResult() {
- }
-
- private WxPayAppOrderResult(Builder builder) {
- setSign(builder.sign);
- setPrepayId(builder.prepayId);
- setPartnerId(builder.partnerId);
- setAppId(builder.appId);
- setPackageValue(builder.packageValue);
- setTimeStamp(builder.timeStamp);
- setNonceStr(builder.nonceStr);
- }
-
- public static Builder newBuilder() {
- return new Builder();
- }
-
- public String getSign() {
- return this.sign;
- }
-
- public void setSign(String sign) {
- this.sign = sign;
- }
-
- public String getPrepayId() {
- return this.prepayId;
- }
-
- public void setPrepayId(String prepayId) {
- this.prepayId = prepayId;
- }
-
- public String getPartnerId() {
- return this.partnerId;
- }
-
- public void setPartnerId(String partnerId) {
- this.partnerId = partnerId;
- }
-
- public String getAppId() {
- return this.appId;
- }
-
- public void setAppId(String appId) {
- this.appId = appId;
- }
-
- public String getPackageValue() {
- return this.packageValue;
- }
-
- public void setPackageValue(String packageValue) {
- this.packageValue = packageValue;
- }
-
- public String getTimeStamp() {
- return this.timeStamp;
- }
-
- public void setTimeStamp(String timeStamp) {
- this.timeStamp = timeStamp;
- }
-
- public String getNonceStr() {
- return this.nonceStr;
- }
-
- public void setNonceStr(String nonceStr) {
- this.nonceStr = nonceStr;
- }
-
- public static final class Builder {
- private String sign;
- private String prepayId;
- private String partnerId;
- private String appId;
- private String packageValue;
- private String timeStamp;
- private String nonceStr;
-
- private Builder() {
- }
-
- public Builder sign(String sign) {
- this.sign = sign;
- return this;
- }
-
- public Builder prepayId(String prepayId) {
- this.prepayId = prepayId;
- return this;
- }
-
- public Builder partnerId(String partnerId) {
- this.partnerId = partnerId;
- return this;
- }
-
- public Builder appId(String appId) {
- this.appId = appId;
- return this;
- }
-
- public Builder packageValue(String packageValue) {
- this.packageValue = packageValue;
- return this;
- }
-
- public Builder timeStamp(String timeStamp) {
- this.timeStamp = timeStamp;
- return this;
- }
-
- public Builder nonceStr(String nonceStr) {
- this.nonceStr = nonceStr;
- return this;
- }
-
- public WxPayAppOrderResult build() {
- return new WxPayAppOrderResult(this);
- }
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java
index d1ebdee051..4fded06fdf 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java
@@ -1,5 +1,9 @@
package com.github.binarywang.wxpay.bean.order;
+import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Builder;
+import lombok.Data;
+
/**
*
* 微信公众号支付进行统一下单后组装所需参数的类
@@ -9,6 +13,8 @@
*
* @author Binary Wang
*/
+@Data
+@Builder
public class WxPayMpOrderResult {
private String appId;
private String timeStamp;
@@ -16,118 +22,8 @@ public class WxPayMpOrderResult {
/**
* 由于package为java保留关键字,因此改为packageValue
*/
+ @XStreamAlias("package")
private String packageValue;
private String signType;
private String paySign;
-
- private WxPayMpOrderResult(Builder builder) {
- setAppId(builder.appId);
- setTimeStamp(builder.timeStamp);
- setNonceStr(builder.nonceStr);
- setPackageValue(builder.packageValue);
- setSignType(builder.signType);
- setPaySign(builder.paySign);
- }
-
- public static Builder newBuilder() {
- return new Builder();
- }
-
- public String getAppId() {
- return this.appId;
- }
-
- public void setAppId(String appId) {
- this.appId = appId;
- }
-
- public String getTimeStamp() {
- return this.timeStamp;
- }
-
- public void setTimeStamp(String timeStamp) {
- this.timeStamp = timeStamp;
- }
-
- public String getNonceStr() {
- return this.nonceStr;
- }
-
- public void setNonceStr(String nonceStr) {
- this.nonceStr = nonceStr;
- }
-
- public String getPackageValue() {
- return this.packageValue;
- }
-
- public void setPackageValue(String packageValue) {
- this.packageValue = packageValue;
- }
-
- public String getSignType() {
- return this.signType;
- }
-
- public void setSignType(String signType) {
- this.signType = signType;
- }
-
- public String getPaySign() {
- return this.paySign;
- }
-
- public void setPaySign(String paySign) {
- this.paySign = paySign;
- }
-
- public WxPayMpOrderResult() {
- }
-
-
- public static final class Builder {
- private String appId;
- private String timeStamp;
- private String nonceStr;
- private String packageValue;
- private String signType;
- private String paySign;
-
- private Builder() {
- }
-
- public Builder appId(String appId) {
- this.appId = appId;
- return this;
- }
-
- public Builder timeStamp(String timeStamp) {
- this.timeStamp = timeStamp;
- return this;
- }
-
- public Builder nonceStr(String nonceStr) {
- this.nonceStr = nonceStr;
- return this;
- }
-
- public Builder packageValue(String packageValue) {
- this.packageValue = packageValue;
- return this;
- }
-
- public Builder signType(String signType) {
- this.signType = signType;
- return this;
- }
-
- public Builder paySign(String paySign) {
- this.paySign = paySign;
- return this;
- }
-
- public WxPayMpOrderResult build() {
- return new WxPayMpOrderResult(this);
- }
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayNativeOrderResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayNativeOrderResult.java
index 3eb0e3748a..99788c2bc9 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayNativeOrderResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayNativeOrderResult.java
@@ -1,5 +1,8 @@
package com.github.binarywang.wxpay.bean.order;
+import lombok.Builder;
+import lombok.Data;
+
/**
*
* 微信扫码支付统一下单后发起支付拼接所需参数实现类
@@ -8,41 +11,8 @@
*
* @author Binary Wang
*/
+@Data
+@Builder
public class WxPayNativeOrderResult {
private String codeUrl;
-
- private WxPayNativeOrderResult(Builder builder) {
- setCodeUrl(builder.codeUrl);
- }
-
- public static Builder newBuilder() {
- return new Builder();
- }
-
- public String getCodeUrl() {
- return this.codeUrl;
- }
-
- public void setCodeUrl(String codeUrl) {
- this.codeUrl = codeUrl;
- }
-
- public WxPayNativeOrderResult() {
- }
-
- public static final class Builder {
- private String codeUrl;
-
- private Builder() {
- }
-
- public Builder codeUrl(String codeUrl) {
- this.codeUrl = codeUrl;
- return this;
- }
-
- public WxPayNativeOrderResult build() {
- return new WxPayNativeOrderResult(this);
- }
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayQueryRequest.java
index f9135c34df..5d48bb4463 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayQueryRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayQueryRequest.java
@@ -1,6 +1,7 @@
package com.github.binarywang.wxpay.bean.request;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
import me.chanjar.weixin.common.annotation.Required;
import me.chanjar.weixin.common.util.ToStringUtils;
@@ -17,8 +18,13 @@
*
* Created by Binary Wang on 2016/10/19.
*
- * @author binarywang (https://github.com/binarywang)
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxEntPayQueryRequest extends WxPayBaseRequest {
/**
@@ -35,14 +41,6 @@ public class WxEntPayQueryRequest extends WxPayBaseRequest {
@XStreamAlias("partner_trade_no")
private String partnerTradeNo;
- public String getPartnerTradeNo() {
- return this.partnerTradeNo;
- }
-
- public void setPartnerTradeNo(String partnerTradeNo) {
- this.partnerTradeNo = partnerTradeNo;
- }
-
@Override
protected void checkConstraints() {
//do nothing
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayRequest.java
index 7897ad02da..ac588aa55f 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayRequest.java
@@ -1,6 +1,7 @@
package com.github.binarywang.wxpay.bean.request;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
import me.chanjar.weixin.common.annotation.Required;
import me.chanjar.weixin.common.util.ToStringUtils;
@@ -10,8 +11,14 @@
*
* Created by Binary Wang on 2016/10/02.
*
- * @author binarywang (https://github.com/binarywang)
+ * @author Binary Wang
*/
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxEntPayRequest extends WxPayBaseRequest {
/**
@@ -153,32 +160,6 @@ public class WxEntPayRequest extends WxPayBaseRequest {
@XStreamAlias("spbill_create_ip")
private String spbillCreateIp;
- public WxEntPayRequest() {
- }
-
- private WxEntPayRequest(Builder builder) {
- setAppid(builder.appid);
- setMchId(builder.mchId);
- setSubAppId(builder.subAppId);
- setSubMchId(builder.subMchId);
- setNonceStr(builder.nonceStr);
- setSign(builder.sign);
- mchAppid = builder.mchAppid;
- setMchId(builder.mchId);
- setDeviceInfo(builder.deviceInfo);
- setPartnerTradeNo(builder.partnerTradeNo);
- setOpenid(builder.openid);
- setCheckName(builder.checkName);
- setReUserName(builder.reUserName);
- setAmount(builder.amount);
- setDescription(builder.description);
- setSpbillCreateIp(builder.spbillCreateIp);
- }
-
- public static Builder newBuilder() {
- return new Builder();
- }
-
@Override
protected void checkConstraints() {
@@ -204,172 +185,9 @@ public void setMchId(String mchId) {
this.mchId = mchId;
}
- public String getDeviceInfo() {
- return this.deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getPartnerTradeNo() {
- return this.partnerTradeNo;
- }
-
- public void setPartnerTradeNo(String partnerTradeNo) {
- this.partnerTradeNo = partnerTradeNo;
- }
-
- public String getOpenid() {
- return this.openid;
- }
-
- public void setOpenid(String openid) {
- this.openid = openid;
- }
-
- public String getCheckName() {
- return this.checkName;
- }
-
- public void setCheckName(String checkName) {
- this.checkName = checkName;
- }
-
- public String getReUserName() {
- return this.reUserName;
- }
-
- public void setReUserName(String reUserName) {
- this.reUserName = reUserName;
- }
-
- public Integer getAmount() {
- return this.amount;
- }
-
- public void setAmount(Integer amount) {
- this.amount = amount;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getSpbillCreateIp() {
- return this.spbillCreateIp;
- }
-
- public void setSpbillCreateIp(String spbillCreateIp) {
- this.spbillCreateIp = spbillCreateIp;
- }
-
@Override
public String toString() {
return ToStringUtils.toSimpleString(this);
}
- public static final class Builder {
- private String appid;
- private String mchId;
- private String deviceInfo;
- private String partnerTradeNo;
- private String openid;
- private String checkName;
- private String reUserName;
- private Integer amount;
- private String description;
- private String spbillCreateIp;
- private String subAppId;
- private String subMchId;
- private String nonceStr;
- private String sign;
- private String mchAppid;
-
- private Builder() {
- }
-
- public Builder appid(String appid) {
- this.appid = appid;
- return this;
- }
-
- public Builder mchId(String mchId) {
- this.mchId = mchId;
- return this;
- }
-
- public Builder deviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- return this;
- }
-
- public Builder partnerTradeNo(String partnerTradeNo) {
- this.partnerTradeNo = partnerTradeNo;
- return this;
- }
-
- public Builder openid(String openid) {
- this.openid = openid;
- return this;
- }
-
- public Builder checkName(String checkName) {
- this.checkName = checkName;
- return this;
- }
-
- public Builder reUserName(String reUserName) {
- this.reUserName = reUserName;
- return this;
- }
-
- public Builder amount(Integer amount) {
- this.amount = amount;
- return this;
- }
-
- public Builder description(String description) {
- this.description = description;
- return this;
- }
-
- public Builder spbillCreateIp(String spbillCreateIp) {
- this.spbillCreateIp = spbillCreateIp;
- return this;
- }
-
- public WxEntPayRequest build() {
- return new WxEntPayRequest(this);
- }
-
- public Builder subAppId(String subAppId) {
- this.subAppId = subAppId;
- return this;
- }
-
- public Builder subMchId(String subMchId) {
- this.subMchId = subMchId;
- return this;
- }
-
- public Builder nonceStr(String nonceStr) {
- this.nonceStr = nonceStr;
- return this;
- }
-
- public Builder sign(String sign) {
- this.sign = sign;
- return this;
- }
-
- public Builder mchAppid(String mchAppid) {
- this.mchAppid = mchAppid;
- return this;
- }
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayAuthcode2OpenidRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayAuthcode2OpenidRequest.java
index 594fa4960d..1187bf8df5 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayAuthcode2OpenidRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayAuthcode2OpenidRequest.java
@@ -1,14 +1,21 @@
package com.github.binarywang.wxpay.bean.request;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
/**
*
* 授权码查询openid接口请求对象类
* Created by Binary Wang on 2017-3-27.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayAuthcode2OpenidRequest extends WxPayBaseRequest {
@@ -24,21 +31,6 @@ public class WxPayAuthcode2OpenidRequest extends WxPayBaseRequest {
@XStreamAlias("auth_code")
private String authCode;
- public WxPayAuthcode2OpenidRequest() {
- }
-
- public WxPayAuthcode2OpenidRequest(String authCode) {
- this.authCode = authCode;
- }
-
- public String getAuthCode() {
- return this.authCode;
- }
-
- public void setAuthCode(String authCode) {
- this.authCode = authCode;
- }
-
@Override
protected void checkConstraints() {
// nothing to do
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java
index 41a98d0ae4..7147adfec7 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java
@@ -5,6 +5,7 @@
import com.github.binarywang.wxpay.util.SignUtils;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.BeanUtils;
import me.chanjar.weixin.common.util.ToStringUtils;
@@ -13,14 +14,17 @@
import java.math.BigDecimal;
+import static com.github.binarywang.wxpay.constant.WxPayConstants.SignType.ALL_SIGN_TYPES;
+
/**
*
* Created by Binary Wang on 2016-10-24.
* 微信支付请求对象共用的参数存放类
*
*
- * @author binarywang(Binary Wang)
+ * @author Binary Wang
*/
+@Data
public abstract class WxPayBaseRequest {
/**
*
@@ -120,7 +124,7 @@ public static Integer yuanToFee(String yuan) {
/**
* 检查请求参数内容,包括必填参数以及特殊约束
*/
- protected void checkFields() throws WxPayException {
+ private void checkFields() throws WxPayException {
//check required fields
try {
BeanUtils.checkRequiredFields(this);
@@ -137,10 +141,6 @@ protected void checkFields() throws WxPayException {
*/
protected abstract void checkConstraints() throws WxPayException;
- public String getAppid() {
- return this.appid;
- }
-
/**
* 如果配置中已经设置,可以不设置值
*
@@ -150,10 +150,6 @@ public void setAppid(String appid) {
this.appid = appid;
}
- public String getMchId() {
- return this.mchId;
- }
-
/**
* 如果配置中已经设置,可以不设置值
*
@@ -163,10 +159,6 @@ public void setMchId(String mchId) {
this.mchId = mchId;
}
- public String getNonceStr() {
- return this.nonceStr;
- }
-
/**
* 默认采用时间戳为随机字符串,可以不设置
*
@@ -176,38 +168,6 @@ public void setNonceStr(String nonceStr) {
this.nonceStr = nonceStr;
}
- public String getSign() {
- return this.sign;
- }
-
- public void setSign(String sign) {
- this.sign = sign;
- }
-
- public String getSubAppId() {
- return subAppId;
- }
-
- public void setSubAppId(String subAppId) {
- this.subAppId = subAppId;
- }
-
- public String getSubMchId() {
- return subMchId;
- }
-
- public void setSubMchId(String subMchId) {
- this.subMchId = subMchId;
- }
-
- public String getSignType() {
- return signType;
- }
-
- public void setSignType(String signType) {
- this.signType = signType;
- }
-
@Override
public String toString() {
return ToStringUtils.toSimpleString(this);
@@ -215,6 +175,9 @@ public String toString() {
public String toXML() {
XStream xstream = XStreamInitializer.getInstance();
+ //涉及到服务商模式的两个参数,在为空值时置为null,以免在请求时将空值传给微信服务器
+ this.setSubAppId(StringUtils.trimToNull(this.getSubAppId()));
+ this.setSubMchId(StringUtils.trimToNull(this.getSubMchId()));
xstream.processAnnotations(this.getClass());
return xstream.toXML(this);
}
@@ -227,9 +190,10 @@ public String toXML() {
* 3、生成签名,并设置进去
*
*
- * @param config 支付配置对象,用于读取相应系统配置信息
+ * @param config 支付配置对象,用于读取相应系统配置信息
+ * @param isIgnoreSignType 签名时,是否忽略signType
*/
- public void checkAndSign(WxPayConfig config) throws WxPayException {
+ public void checkAndSign(WxPayConfig config, boolean isIgnoreSignType) throws WxPayException {
this.checkFields();
if (StringUtils.isBlank(getAppid())) {
@@ -248,11 +212,24 @@ public void checkAndSign(WxPayConfig config) throws WxPayException {
this.setSubMchId(config.getSubMchId());
}
+ if (StringUtils.isBlank(getSignType())) {
+ if (config.getSignType() != null && !ALL_SIGN_TYPES.contains(config.getSignType())) {
+ throw new WxPayException("非法的signType配置:" + config.getSignType() + ",请检查配置!");
+ }
+ this.setSignType(StringUtils.trimToNull(config.getSignType()));
+ } else {
+ if (!ALL_SIGN_TYPES.contains(this.getSignType())) {
+ throw new WxPayException("非法的sign_type参数:" + this.getSignType());
+ }
+ }
+
if (StringUtils.isBlank(getNonceStr())) {
this.setNonceStr(String.valueOf(System.currentTimeMillis()));
}
+
//设置签名字段的值
- this.setSign(SignUtils.createSign(this, config.getMchKey(), this.signType));
+ this.setSign(SignUtils.createSign(this, this.getSignType(), config.getMchKey(),
+ isIgnoreSignType));
}
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadBillRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadBillRequest.java
index 33e410cdd8..6dc7264b33 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadBillRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadBillRequest.java
@@ -3,6 +3,7 @@
import com.github.binarywang.wxpay.constant.WxPayConstants.BillType;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
import me.chanjar.weixin.common.annotation.Required;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
@@ -13,9 +14,15 @@
*
* 微信支付下载对账单请求参数类
* Created by Binary Wang on 2017-01-11.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayDownloadBillRequest extends WxPayBaseRequest {
private static final String[] BILL_TYPES = new String[]{BillType.ALL, BillType.SUCCESS, BillType.REFUND, BillType.RECHARGE_REFUND};
@@ -34,19 +41,6 @@ public class WxPayDownloadBillRequest extends WxPayBaseRequest {
@XStreamAlias("device_info")
private String deviceInfo;
- /**
- *
- * 签名类型
- * sign_type
- * 否
- * String(32)
- * HMAC-SHA256
- * 签名类型,目前支持HMAC-SHA256和MD5,默认为MD5
- *
- */
- @XStreamAlias("sign_type")
- private String signType;
-
/**
*
* 账单类型
@@ -90,46 +84,6 @@ public class WxPayDownloadBillRequest extends WxPayBaseRequest {
@XStreamAlias("tar_type")
private String tarType;
- public String getDeviceInfo() {
- return deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getSignType() {
- return signType;
- }
-
- public void setSignType(String signType) {
- this.signType = signType;
- }
-
- public String getBillType() {
- return billType;
- }
-
- public void setBillType(String billType) {
- this.billType = billType;
- }
-
- public String getBillDate() {
- return billDate;
- }
-
- public void setBillDate(String billDate) {
- this.billDate = billDate;
- }
-
- public String getTarType() {
- return tarType;
- }
-
- public void setTarType(String tarType) {
- this.tarType = tarType;
- }
-
@Override
protected void checkConstraints() throws WxPayException {
if (StringUtils.isNotBlank(this.getTarType()) && !TAR_TYPE_GZIP.equals(this.getTarType())) {
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayMicropayRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayMicropayRequest.java
index a025337806..ed85fe76cf 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayMicropayRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayMicropayRequest.java
@@ -1,29 +1,24 @@
package com.github.binarywang.wxpay.bean.request;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
import me.chanjar.weixin.common.annotation.Required;
/**
*
* 提交刷卡支付请求对象类
* Created by Binary Wang on 2017-3-23.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayMicropayRequest extends WxPayBaseRequest {
- /**
- *
- * 签名类型
- * sign_type
- * 否
- * String(32)
- * HMAC-SHA256
- * 签名类型,目前支持HMAC-SHA256和MD5,默认为MD5
- **/
- @XStreamAlias("sign_type")
- private String signType;
-
/**
*
* 商品描述
@@ -149,232 +144,9 @@ public class WxPayMicropayRequest extends WxPayBaseRequest {
@XStreamAlias("auth_code")
private String authCode;
- private WxPayMicropayRequest(Builder builder) {
- setSignType(builder.signType);
- setBody(builder.body);
- setAppid(builder.appid);
- setDetail(builder.detail);
- setMchId(builder.mchId);
- setAttach(builder.attach);
- setSubAppId(builder.subAppId);
- setOutTradeNo(builder.outTradeNo);
- setSubMchId(builder.subMchId);
- setTotalFee(builder.totalFee);
- setNonceStr(builder.nonceStr);
- setFeeType(builder.feeType);
- setSign(builder.sign);
- setSpbillCreateIp(builder.spbillCreateIp);
- setGoodsTag(builder.goodsTag);
- setLimitPay(builder.limitPay);
- setAuthCode(builder.authCode);
- }
-
- public static Builder newBuilder() {
- return new Builder();
- }
-
- public String getSignType() {
- return this.signType;
- }
-
- public void setSignType(String signType) {
- this.signType = signType;
- }
-
- public String getBody() {
- return this.body;
- }
-
- public void setBody(String body) {
- this.body = body;
- }
-
- public String getDetail() {
- return this.detail;
- }
-
- public void setDetail(String detail) {
- this.detail = detail;
- }
-
- public String getAttach() {
- return this.attach;
- }
-
- public void setAttach(String attach) {
- this.attach = attach;
- }
-
- public String getOutTradeNo() {
- return this.outTradeNo;
- }
-
- public void setOutTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- }
-
- public Integer getTotalFee() {
- return this.totalFee;
- }
-
- public void setTotalFee(Integer totalFee) {
- this.totalFee = totalFee;
- }
-
- public String getFeeType() {
- return this.feeType;
- }
-
- public void setFeeType(String feeType) {
- this.feeType = feeType;
- }
-
- public String getSpbillCreateIp() {
- return this.spbillCreateIp;
- }
-
- public void setSpbillCreateIp(String spbillCreateIp) {
- this.spbillCreateIp = spbillCreateIp;
- }
-
- public String getGoodsTag() {
- return this.goodsTag;
- }
-
- public void setGoodsTag(String goodsTag) {
- this.goodsTag = goodsTag;
- }
-
- public String getLimitPay() {
- return this.limitPay;
- }
-
- public void setLimitPay(String limitPay) {
- this.limitPay = limitPay;
- }
-
- public String getAuthCode() {
- return this.authCode;
- }
-
- public void setAuthCode(String authCode) {
- this.authCode = authCode;
- }
-
@Override
protected void checkConstraints() {
//do nothing
}
- public static final class Builder {
- private String signType;
- private String body;
- private String appid;
- private String detail;
- private String mchId;
- private String attach;
- private String subAppId;
- private String outTradeNo;
- private String subMchId;
- private Integer totalFee;
- private String nonceStr;
- private String feeType;
- private String sign;
- private String spbillCreateIp;
- private String goodsTag;
- private String limitPay;
- private String authCode;
-
- private Builder() {
- }
-
- public Builder signType(String signType) {
- this.signType = signType;
- return this;
- }
-
- public Builder body(String body) {
- this.body = body;
- return this;
- }
-
- public Builder appid(String appid) {
- this.appid = appid;
- return this;
- }
-
- public Builder detail(String detail) {
- this.detail = detail;
- return this;
- }
-
- public Builder mchId(String mchId) {
- this.mchId = mchId;
- return this;
- }
-
- public Builder attach(String attach) {
- this.attach = attach;
- return this;
- }
-
- public Builder subAppId(String subAppId) {
- this.subAppId = subAppId;
- return this;
- }
-
- public Builder outTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- return this;
- }
-
- public Builder subMchId(String subMchId) {
- this.subMchId = subMchId;
- return this;
- }
-
- public Builder totalFee(Integer totalFee) {
- this.totalFee = totalFee;
- return this;
- }
-
- public Builder nonceStr(String nonceStr) {
- this.nonceStr = nonceStr;
- return this;
- }
-
- public Builder feeType(String feeType) {
- this.feeType = feeType;
- return this;
- }
-
- public Builder sign(String sign) {
- this.sign = sign;
- return this;
- }
-
- public Builder spbillCreateIp(String spbillCreateIp) {
- this.spbillCreateIp = spbillCreateIp;
- return this;
- }
-
- public Builder goodsTag(String goodsTag) {
- this.goodsTag = goodsTag;
- return this;
- }
-
- public Builder limitPay(String limitPay) {
- this.limitPay = limitPay;
- return this;
- }
-
- public Builder authCode(String authCode) {
- this.authCode = authCode;
- return this;
- }
-
- public WxPayMicropayRequest build() {
- return new WxPayMicropayRequest(this);
- }
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderCloseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderCloseRequest.java
index 21968ac983..29650537c3 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderCloseRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderCloseRequest.java
@@ -1,14 +1,21 @@
package com.github.binarywang.wxpay.bean.request;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
/**
*
* 关闭订单请求对象类
* Created by Binary Wang on 2016-10-27.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayOrderCloseRequest extends WxPayBaseRequest {
@@ -25,14 +32,6 @@ public class WxPayOrderCloseRequest extends WxPayBaseRequest {
@XStreamAlias("out_trade_no")
private String outTradeNo;
- public String getOutTradeNo() {
- return this.outTradeNo;
- }
-
- public void setOutTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- }
-
@Override
protected void checkConstraints() {
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderQueryRequest.java
index e7767da607..4342fb9519 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderQueryRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderQueryRequest.java
@@ -2,6 +2,7 @@
import com.github.binarywang.wxpay.exception.WxPayException;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
import org.apache.commons.lang3.StringUtils;
/**
@@ -17,8 +18,13 @@
* 描述
*
*
- * @author binarywang(Binary Wang)
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayOrderQueryRequest extends WxPayBaseRequest {
@@ -48,22 +54,6 @@ public class WxPayOrderQueryRequest extends WxPayBaseRequest {
@XStreamAlias("out_trade_no")
private String outTradeNo;
- public String getTransactionId() {
- return this.transactionId;
- }
-
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
- }
-
- public String getOutTradeNo() {
- return this.outTradeNo;
- }
-
- public void setOutTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- }
-
@Override
protected void checkConstraints() throws WxPayException {
if ((StringUtils.isBlank(transactionId) && StringUtils.isBlank(outTradeNo)) ||
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderReverseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderReverseRequest.java
index 075295238e..db68179188 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderReverseRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderReverseRequest.java
@@ -2,15 +2,22 @@
import com.github.binarywang.wxpay.exception.WxPayException;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
import org.apache.commons.lang3.StringUtils;
/**
*
* 撤销订单请求类
* Created by Binary Wang on 2017-3-23.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayOrderReverseRequest extends WxPayBaseRequest {
@@ -39,58 +46,6 @@ public class WxPayOrderReverseRequest extends WxPayBaseRequest {
@XStreamAlias("out_trade_no")
private String outTradeNo;
- /**
- *
- * 签名类型
- * sign_type
- * 否
- * String(32)
- * HMAC-SHA256
- * 签名类型,目前支持HMAC-SHA256和MD5,默认为MD5
- **/
- @XStreamAlias("sign_type")
- private String signType;
-
- private WxPayOrderReverseRequest(Builder builder) {
- setTransactionId(builder.transactionId);
- setAppid(builder.appid);
- setOutTradeNo(builder.outTradeNo);
- setMchId(builder.mchId);
- setSignType(builder.signType);
- setSubAppId(builder.subAppId);
- setSubMchId(builder.subMchId);
- setNonceStr(builder.nonceStr);
- setSign(builder.sign);
- }
-
- public static Builder newBuilder() {
- return new Builder();
- }
-
- public String getTransactionId() {
- return this.transactionId;
- }
-
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
- }
-
- public String getOutTradeNo() {
- return this.outTradeNo;
- }
-
- public void setOutTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- }
-
- public String getSignType() {
- return this.signType;
- }
-
- public void setSignType(String signType) {
- this.signType = signType;
- }
-
@Override
protected void checkConstraints() throws WxPayException {
if (StringUtils.isBlank(transactionId) && StringUtils.isBlank(outTradeNo)) {
@@ -98,67 +53,4 @@ protected void checkConstraints() throws WxPayException {
}
}
- public static final class Builder {
- private String transactionId;
- private String appid;
- private String outTradeNo;
- private String mchId;
- private String signType;
- private String subAppId;
- private String subMchId;
- private String nonceStr;
- private String sign;
-
- private Builder() {
- }
-
- public Builder transactionId(String transactionId) {
- this.transactionId = transactionId;
- return this;
- }
-
- public Builder appid(String appid) {
- this.appid = appid;
- return this;
- }
-
- public Builder outTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- return this;
- }
-
- public Builder mchId(String mchId) {
- this.mchId = mchId;
- return this;
- }
-
- public Builder signType(String signType) {
- this.signType = signType;
- return this;
- }
-
- public Builder subAppId(String subAppId) {
- this.subAppId = subAppId;
- return this;
- }
-
- public Builder subMchId(String subMchId) {
- this.subMchId = subMchId;
- return this;
- }
-
- public Builder nonceStr(String nonceStr) {
- this.nonceStr = nonceStr;
- return this;
- }
-
- public Builder sign(String sign) {
- this.sign = sign;
- return this;
- }
-
- public WxPayOrderReverseRequest build() {
- return new WxPayOrderReverseRequest(this);
- }
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryCommentRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryCommentRequest.java
index 1bdbf9bf4e..e1117b0be2 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryCommentRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryCommentRequest.java
@@ -2,6 +2,7 @@
import com.github.binarywang.wxpay.exception.WxPayException;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
import me.chanjar.weixin.common.annotation.Required;
/**
@@ -12,6 +13,11 @@
*
* @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayQueryCommentRequest extends WxPayBaseRequest {
/**
@@ -77,36 +83,4 @@ protected void checkConstraints() throws WxPayException {
}
- public String getBeginTime() {
- return beginTime;
- }
-
- public void setBeginTime(String beginTime) {
- this.beginTime = beginTime;
- }
-
- public String getEndTime() {
- return endTime;
- }
-
- public void setEndTime(String endTime) {
- this.endTime = endTime;
- }
-
- public Integer getOffset() {
- return offset;
- }
-
- public void setOffset(Integer offset) {
- this.offset = offset;
- }
-
- public Integer getLimit() {
- return limit;
- }
-
- public void setLimit(Integer limit) {
- this.limit = limit;
- }
-
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRedpackQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRedpackQueryRequest.java
index 191db46975..e7b5f9c134 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRedpackQueryRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRedpackQueryRequest.java
@@ -1,6 +1,7 @@
package com.github.binarywang.wxpay.bean.request;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
/**
*
@@ -12,9 +13,15 @@
* 类型
* 说明
* Created by Binary Wang on 2016-11-28.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayRedpackQueryRequest extends WxPayBaseRequest {
/**
@@ -39,22 +46,6 @@ public class WxPayRedpackQueryRequest extends WxPayBaseRequest {
@XStreamAlias("bill_type")
private String billType;
- public String getBillType() {
- return billType;
- }
-
- public void setBillType(String billType) {
- this.billType = billType;
- }
-
- public String getMchBillNo() {
- return mchBillNo;
- }
-
- public void setMchBillNo(String mchBillNo) {
- this.mchBillNo = mchBillNo;
- }
-
@Override
protected void checkConstraints() {
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundQueryRequest.java
index 00545f004c..e413377f34 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundQueryRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundQueryRequest.java
@@ -2,14 +2,21 @@
import com.github.binarywang.wxpay.exception.WxPayException;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
import org.apache.commons.lang3.StringUtils;
/**
*
* Created by Binary Wang on 2016-11-24.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayRefundQueryRequest extends WxPayBaseRequest {
/**
@@ -25,19 +32,6 @@ public class WxPayRefundQueryRequest extends WxPayBaseRequest {
@XStreamAlias("device_info")
private String deviceInfo;
- /**
- *
- * 签名类型
- * sign_type
- * 否
- * String(32)
- * HMAC-SHA256
- * 签名类型,目前支持HMAC-SHA256和MD5,默认为MD5
- *
- */
- @XStreamAlias("sign_type")
- private String signType;
-
//************以下四选一************
/**
*
@@ -87,54 +81,6 @@ public class WxPayRefundQueryRequest extends WxPayBaseRequest {
@XStreamAlias("refund_id")
private String refundId;
- public String getDeviceInfo() {
- return deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getSignType() {
- return signType;
- }
-
- public void setSignType(String signType) {
- this.signType = signType;
- }
-
- public String getTransactionId() {
- return transactionId;
- }
-
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
- }
-
- public String getOutTradeNo() {
- return outTradeNo;
- }
-
- public void setOutTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- }
-
- public String getOutRefundNo() {
- return outRefundNo;
- }
-
- public void setOutRefundNo(String outRefundNo) {
- this.outRefundNo = outRefundNo;
- }
-
- public String getRefundId() {
- return refundId;
- }
-
- public void setRefundId(String refundId) {
- this.refundId = refundId;
- }
-
@Override
protected void checkConstraints() throws WxPayException {
if ((StringUtils.isBlank(transactionId) && StringUtils.isBlank(outTradeNo)
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java
index 66808738ca..1a3b85e83a 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java
@@ -1,8 +1,10 @@
package com.github.binarywang.wxpay.bean.request;
import com.github.binarywang.wxpay.config.WxPayConfig;
+import com.github.binarywang.wxpay.constant.WxPayConstants.RefundAccountSource;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
import me.chanjar.weixin.common.annotation.Required;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
@@ -22,12 +24,19 @@
* Created by Binary Wang on 2016-10-08.
*
*
- * @author binarywang(Binary Wang)
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayRefundRequest extends WxPayBaseRequest {
- private static final String[] REFUND_ACCOUNT = new String[]{"REFUND_SOURCE_RECHARGE_FUNDS",
- "REFUND_SOURCE_UNSETTLED_FUNDS"};
+ private static final String[] REFUND_ACCOUNT = new String[]{
+ RefundAccountSource.RECHARGE_FUNDS,
+ RefundAccountSource.UNSETTLED_FUNDS
+ };
/**
*
* 设备号
@@ -155,119 +164,13 @@ public class WxPayRefundRequest extends WxPayBaseRequest {
@XStreamAlias("refund_desc")
private String refundDesc;
- private WxPayRefundRequest(Builder builder) {
- setDeviceInfo(builder.deviceInfo);
- setAppid(builder.appid);
- setTransactionId(builder.transactionId);
- setMchId(builder.mchId);
- setSubAppId(builder.subAppId);
- setOutTradeNo(builder.outTradeNo);
- setSubMchId(builder.subMchId);
- setOutRefundNo(builder.outRefundNo);
- setNonceStr(builder.nonceStr);
- setTotalFee(builder.totalFee);
- setSign(builder.sign);
- setRefundFee(builder.refundFee);
- setRefundFeeType(builder.refundFeeType);
- setOpUserId(builder.opUserId);
- setRefundAccount(builder.refundAccount);
- setRefundDesc(builder.refundDesc);
- }
-
- public static Builder newBuilder() {
- return new Builder();
- }
-
- public String getDeviceInfo() {
- return this.deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getTransactionId() {
- return this.transactionId;
- }
-
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
- }
-
- public String getOutTradeNo() {
- return this.outTradeNo;
- }
-
- public void setOutTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- }
-
- public String getOutRefundNo() {
- return this.outRefundNo;
- }
-
- public void setOutRefundNo(String outRefundNo) {
- this.outRefundNo = outRefundNo;
- }
-
- public Integer getTotalFee() {
- return this.totalFee;
- }
-
- public void setTotalFee(Integer totalFee) {
- this.totalFee = totalFee;
- }
-
- public Integer getRefundFee() {
- return this.refundFee;
- }
-
- public void setRefundFee(Integer refundFee) {
- this.refundFee = refundFee;
- }
-
- public String getRefundFeeType() {
- return this.refundFeeType;
- }
-
- public void setRefundFeeType(String refundFeeType) {
- this.refundFeeType = refundFeeType;
- }
-
- public String getOpUserId() {
- return this.opUserId;
- }
-
- public void setOpUserId(String opUserId) {
- this.opUserId = opUserId;
- }
-
- public String getRefundAccount() {
- return this.refundAccount;
- }
-
- public void setRefundAccount(String refundAccount) {
- this.refundAccount = refundAccount;
- }
-
- public String getRefundDesc() {
- return this.refundDesc;
- }
-
- public void setRefundDesc(String refundDesc) {
- this.refundDesc = refundDesc;
- }
-
- public WxPayRefundRequest() {
- }
-
@Override
- public void checkAndSign(WxPayConfig config) throws WxPayException {
+ public void checkAndSign(WxPayConfig config, boolean isIgnoreSignType) throws WxPayException {
if (StringUtils.isBlank(this.getOpUserId())) {
this.setOpUserId(config.getMchId());
}
- super.checkAndSign(config);
+ super.checkAndSign(config, isIgnoreSignType);
}
@Override
@@ -284,109 +187,4 @@ protected void checkConstraints() throws WxPayException {
}
}
- public static final class Builder {
- private String deviceInfo;
- private String appid;
- private String transactionId;
- private String mchId;
- private String subAppId;
- private String outTradeNo;
- private String subMchId;
- private String outRefundNo;
- private String nonceStr;
- private Integer totalFee;
- private String sign;
- private Integer refundFee;
- private String refundFeeType;
- private String opUserId;
- private String refundAccount;
- private String refundDesc;
-
- private Builder() {
- }
-
- public Builder deviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- return this;
- }
-
- public Builder appid(String appid) {
- this.appid = appid;
- return this;
- }
-
- public Builder transactionId(String transactionId) {
- this.transactionId = transactionId;
- return this;
- }
-
- public Builder mchId(String mchId) {
- this.mchId = mchId;
- return this;
- }
-
- public Builder subAppId(String subAppId) {
- this.subAppId = subAppId;
- return this;
- }
-
- public Builder outTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- return this;
- }
-
- public Builder subMchId(String subMchId) {
- this.subMchId = subMchId;
- return this;
- }
-
- public Builder outRefundNo(String outRefundNo) {
- this.outRefundNo = outRefundNo;
- return this;
- }
-
- public Builder nonceStr(String nonceStr) {
- this.nonceStr = nonceStr;
- return this;
- }
-
- public Builder totalFee(Integer totalFee) {
- this.totalFee = totalFee;
- return this;
- }
-
- public Builder sign(String sign) {
- this.sign = sign;
- return this;
- }
-
- public Builder refundFee(Integer refundFee) {
- this.refundFee = refundFee;
- return this;
- }
-
- public Builder refundFeeType(String refundFeeType) {
- this.refundFeeType = refundFeeType;
- return this;
- }
-
- public Builder opUserId(String opUserId) {
- this.opUserId = opUserId;
- return this;
- }
-
- public Builder refundAccount(String refundAccount) {
- this.refundAccount = refundAccount;
- return this;
- }
-
- public Builder refundDesc(String refundDesc) {
- this.refundDesc = refundDesc;
- return this;
- }
-
- public WxPayRefundRequest build() {
- return new WxPayRefundRequest(this);
- }
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayReportRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayReportRequest.java
index 8b3f88b9c9..88532ad2b5 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayReportRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayReportRequest.java
@@ -1,6 +1,7 @@
package com.github.binarywang.wxpay.bean.request;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
import me.chanjar.weixin.common.annotation.Required;
/**
@@ -15,8 +16,13 @@
* - * 签名类型 - * sign_type - * 否 - * String(32) - * HMAC-SHA256 - * 签名类型,目前支持HMAC-SHA256和MD5,默认为MD5 - *- */ - @XStreamAlias("sign_type") - private String signType; - /** *
* 接口URL
@@ -175,102 +168,6 @@ public class WxPayReportRequest extends WxPayBaseRequest {
@XStreamAlias("time")
private String time;
- public String getDeviceInfo() {
- return deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getSignType() {
- return signType;
- }
-
- public void setSignType(String signType) {
- this.signType = signType;
- }
-
- public String getInterfaceUrl() {
- return interfaceUrl;
- }
-
- public void setInterfaceUrl(String interfaceUrl) {
- this.interfaceUrl = interfaceUrl;
- }
-
- public Integer getExecuteTime() {
- return executeTime;
- }
-
- public void setExecuteTime(Integer executeTime) {
- this.executeTime = executeTime;
- }
-
- public String getReturnCode() {
- return returnCode;
- }
-
- public void setReturnCode(String returnCode) {
- this.returnCode = returnCode;
- }
-
- public String getReturnMsg() {
- return returnMsg;
- }
-
- public void setReturnMsg(String returnMsg) {
- this.returnMsg = returnMsg;
- }
-
- public String getResultCode() {
- return resultCode;
- }
-
- public void setResultCode(String resultCode) {
- this.resultCode = resultCode;
- }
-
- public String getErrCode() {
- return errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-
- public String getErrCodeDes() {
- return errCodeDes;
- }
-
- public void setErrCodeDes(String errCodeDes) {
- this.errCodeDes = errCodeDes;
- }
-
- public String getOutTradeNo() {
- return outTradeNo;
- }
-
- public void setOutTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- }
-
- public String getUserIp() {
- return userIp;
- }
-
- public void setUserIp(String userIp) {
- this.userIp = userIp;
- }
-
- public String getTime() {
- return time;
- }
-
- public void setTime(String time) {
- this.time = time;
- }
-
@Override
protected void checkConstraints() {
//do nothing
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPaySendRedpackRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPaySendRedpackRequest.java
index f7082fc3da..bc621fc011 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPaySendRedpackRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPaySendRedpackRequest.java
@@ -1,13 +1,19 @@
package com.github.binarywang.wxpay.bean.request;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
/**
* 发送红包请求参数对象
* Created by Binary Wang on 2016/9/24.
*
- * @author binarywang (https://github.com/binarywang)
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPaySendRedpackRequest extends WxPayBaseRequest {
/**
@@ -137,85 +143,6 @@ public class WxPaySendRedpackRequest extends WxPayBaseRequest {
@XStreamAlias("consume_mch_id")
private String consumeMchId;
- public String getMchBillNo() {
- return mchBillNo;
- }
-
- public void setMchBillNo(String mchBillNo) {
- this.mchBillNo = mchBillNo;
- }
-
- public String getSendName() {
- return this.sendName;
- }
-
- public void setSendName(String sendName) {
- this.sendName = sendName;
- }
-
- public String getReOpenid() {
- return this.reOpenid;
- }
-
- public void setReOpenid(String reOpenid) {
- this.reOpenid = reOpenid;
- }
-
- public Integer getTotalAmount() {
- return this.totalAmount;
- }
-
- public void setTotalAmount(Integer totalAmount) {
- this.totalAmount = totalAmount;
- }
-
- public Integer getTotalNum() {
- return this.totalNum;
- }
-
- public void setTotalNum(Integer totalNum) {
- this.totalNum = totalNum;
- }
-
- public String getAmtType() {
- return this.amtType;
- }
-
- public void setAmtType(String amtType) {
- this.amtType = amtType;
- }
-
- public String getWishing() {
- return this.wishing;
- }
-
- public void setWishing(String wishing) {
- this.wishing = wishing;
- }
-
- public String getClientIp() {
- return this.clientIp;
- }
-
- public void setClientIp(String clientIp) {
- this.clientIp = clientIp;
- }
-
- public String getActName() {
- return this.actName;
- }
-
- public void setActName(String actName) {
- this.actName = actName;
- }
-
- public String getRemark() {
- return this.remark;
- }
-
- public void setRemark(String remark) {
- this.remark = remark;
- }
@Override
protected void checkConstraints() {
@@ -232,28 +159,4 @@ public void setAppid(String appid) {
this.wxAppid = appid;
}
- public String getSceneId() {
- return this.sceneId;
- }
-
- public void setSceneId(String sceneId) {
- this.sceneId = sceneId;
- }
-
- public String getRiskInfo() {
- return this.riskInfo;
- }
-
- public void setRiskInfo(String riskInfo) {
- this.riskInfo = riskInfo;
- }
-
- public String getConsumeMchId() {
- return this.consumeMchId;
- }
-
- public void setConsumeMchId(String consumeMchId) {
- this.consumeMchId = consumeMchId;
- }
-
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayShorturlRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayShorturlRequest.java
index 714e07ea43..3cc9302bcc 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayShorturlRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayShorturlRequest.java
@@ -1,14 +1,21 @@
package com.github.binarywang.wxpay.bean.request;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
/**
*
* 转换短链接请求对象类
* Created by Binary Wang on 2017-3-27.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayShorturlRequest extends WxPayBaseRequest {
/**
@@ -24,21 +31,6 @@ public class WxPayShorturlRequest extends WxPayBaseRequest {
@XStreamAlias("long_url")
private String longUrl;
- public WxPayShorturlRequest() {
- }
-
- public WxPayShorturlRequest(String longUrl) {
- this.longUrl = longUrl;
- }
-
- public String getLongUrl() {
- return this.longUrl;
- }
-
- public void setLongUrl(String longUrl) {
- this.longUrl = longUrl;
- }
-
@Override
protected void checkConstraints() {
//do nothing
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java
index 8061556cc7..c2bc9f45fb 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java
@@ -1,8 +1,10 @@
package com.github.binarywang.wxpay.bean.request;
import com.github.binarywang.wxpay.config.WxPayConfig;
+import com.github.binarywang.wxpay.constant.WxPayConstants.TradeType;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
import me.chanjar.weixin.common.annotation.Required;
import org.apache.commons.lang3.StringUtils;
@@ -10,15 +12,18 @@
*
* 统一下单请求参数对象
* 参考文档:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1
- *
* Created by Binary Wang on 2016/9/25.
+ *
*
- * @author binarywang (https://github.com/binarywang)
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder(builderMethodName = "newBuilder")
+@NoArgsConstructor
+@AllArgsConstructor
@XStreamAlias("xml")
public class WxPayUnifiedOrderRequest extends WxPayBaseRequest {
- private static final String[] TRADE_TYPES = new String[]{"JSAPI", "NATIVE", "APP", "MWEB"};
-
/**
*
* 字段名:设备号
@@ -310,146 +315,13 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest {
@XStreamAlias("fingerprint")
private String fingerprint;
- public WxPayUnifiedOrderRequest() {
- }
-
- private WxPayUnifiedOrderRequest(Builder builder) {
- setDeviceInfo(builder.deviceInfo);
- setAppid(builder.appid);
- setBody(builder.body);
- setMchId(builder.mchId);
- setSubAppId(builder.subAppId);
- setSubMchId(builder.subMchId);
- setNonceStr(builder.nonceStr);
- setSign(builder.sign);
- setDetail(builder.detail);
- setAttach(builder.attach);
- setOutTradeNo(builder.outTradeNo);
- setFeeType(builder.feeType);
- setTotalFee(builder.totalFee);
- setSpbillCreateIp(builder.spbillCreateIp);
- setTimeStart(builder.timeStart);
- setTimeExpire(builder.timeExpire);
- setGoodsTag(builder.goodsTag);
- setNotifyURL(builder.notifyURL);
- setTradeType(builder.tradeType);
- setProductId(builder.productId);
- setLimitPay(builder.limitPay);
- setOpenid(builder.openid);
- setSubOpenid(builder.subOpenid);
- setSceneInfo(builder.sceneInfo);
- fingerprint = builder.fingerprint;
- }
-
- public static Builder newBuilder() {
- return new Builder();
- }
-
- public String getDeviceInfo() {
- return this.deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getBody() {
- return this.body;
- }
-
- public void setBody(String body) {
- this.body = body;
- }
-
- public String getDetail() {
- return this.detail;
- }
-
- public void setDetail(String detail) {
- this.detail = detail;
- }
-
- public String getAttach() {
- return this.attach;
- }
-
- public void setAttach(String attach) {
- this.attach = attach;
- }
-
- public String getOutTradeNo() {
- return this.outTradeNo;
- }
-
- public void setOutTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- }
-
- public String getFeeType() {
- return this.feeType;
- }
-
- public void setFeeType(String feeType) {
- this.feeType = feeType;
- }
-
- public Integer getTotalFee() {
- return this.totalFee;
- }
-
- public void setTotalFee(Integer totalFee) {
- this.totalFee = totalFee;
- }
-
- public String getSpbillCreateIp() {
- return this.spbillCreateIp;
- }
-
- public void setSpbillCreateIp(String spbillCreateIp) {
- this.spbillCreateIp = spbillCreateIp;
- }
-
- public String getTimeStart() {
- return this.timeStart;
- }
-
- public void setTimeStart(String timeStart) {
- this.timeStart = timeStart;
- }
-
- public String getTimeExpire() {
- return this.timeExpire;
- }
-
- public void setTimeExpire(String timeExpire) {
- this.timeExpire = timeExpire;
- }
-
- public String getGoodsTag() {
- return this.goodsTag;
- }
-
- public void setGoodsTag(String goodsTag) {
- this.goodsTag = goodsTag;
- }
-
- public String getNotifyURL() {
- return this.notifyURL;
- }
-
/**
* 如果配置中已经设置,可以不设置值
- *
- * @param notifyURL
*/
public void setNotifyURL(String notifyURL) {
this.notifyURL = notifyURL;
}
- public String getTradeType() {
- return this.tradeType;
- }
-
/**
* 如果配置中已经设置,可以不设置值
*
@@ -459,64 +331,25 @@ public void setTradeType(String tradeType) {
this.tradeType = tradeType;
}
- public String getProductId() {
- return this.productId;
- }
-
- public void setProductId(String productId) {
- this.productId = productId;
- }
-
- public String getLimitPay() {
- return this.limitPay;
- }
-
- public void setLimitPay(String limitPay) {
- this.limitPay = limitPay;
- }
-
- public String getOpenid() {
- return this.openid;
- }
-
- public void setOpenid(String openid) {
- this.openid = openid;
- }
-
- public String getSubOpenid() {
- return this.subOpenid;
- }
-
- public void setSubOpenid(String subOpenid) {
- this.subOpenid = subOpenid;
- }
-
- public String getSceneInfo() {
- return this.sceneInfo;
- }
-
- public void setSceneInfo(String sceneInfo) {
- this.sceneInfo = sceneInfo;
- }
-
@Override
protected void checkConstraints() throws WxPayException {
-// if (!ArrayUtils.contains(TRADE_TYPES, this.getTradeType())) {
-// throw new WxPayException(String.format("trade_type目前必须为%s其中之一,实际值:%s",
-// Arrays.toString(TRADE_TYPES), this.getTradeType()));
-// }
-
- if ("JSAPI".equals(this.getTradeType()) && this.getOpenid() == null) {
- throw new WxPayException("当 trade_type是'JSAPI'时未指定openid");
+ if (TradeType.JSAPI.equals(this.getTradeType())) {
+ if (StringUtils.isBlank(this.getSubAppId()) && StringUtils.isBlank(this.getOpenid())) {
+ throw new WxPayException("当trade_type是'JSAPI'时,需指定非空的openid值");
+ }
+
+ if (StringUtils.isNotBlank(this.getSubAppId()) && StringUtils.isBlank(this.getSubOpenid())) {
+ throw new WxPayException("在服务商模式下,当trade_type是'JSAPI'时,需指定非空的sub_openid值");
+ }
}
- if ("NATIVE".equals(this.getTradeType()) && this.getProductId() == null) {
- throw new WxPayException("当 trade_type是'NATIVE'时未指定product_id");
+ if (TradeType.NATIVE.equals(this.getTradeType()) && StringUtils.isBlank(this.getProductId())) {
+ throw new WxPayException("当trade_type是'NATIVE'时,需指定非空的product_id值");
}
}
@Override
- public void checkAndSign(WxPayConfig config) throws WxPayException {
+ public void checkAndSign(WxPayConfig config, boolean isIgnoreSignType) throws WxPayException {
if (StringUtils.isBlank(this.getNotifyURL())) {
this.setNotifyURL(config.getNotifyUrl());
}
@@ -525,166 +358,7 @@ public void checkAndSign(WxPayConfig config) throws WxPayException {
this.setTradeType(config.getTradeType());
}
- super.checkAndSign(config);
+ super.checkAndSign(config, isIgnoreSignType);
}
- public static final class Builder {
- private String appid;
- private String mchId;
- private String subAppId;
- private String subMchId;
- private String nonceStr;
- private String sign;
- private String deviceInfo;
- private String body;
- private String detail;
- private String attach;
- private String outTradeNo;
- private String feeType;
- private Integer totalFee;
- private String spbillCreateIp;
- private String timeStart;
- private String timeExpire;
- private String goodsTag;
- private String notifyURL;
- private String tradeType;
- private String productId;
- private String limitPay;
- private String openid;
- private String subOpenid;
- private String sceneInfo;
- private String fingerprint;
-
- private Builder() {
- }
-
- public Builder appid(String appid) {
- this.appid = appid;
- return this;
- }
-
- public Builder mchId(String mchId) {
- this.mchId = mchId;
- return this;
- }
-
- public Builder subAppId(String subAppId) {
- this.subAppId = subAppId;
- return this;
- }
-
- public Builder subMchId(String subMchId) {
- this.subMchId = subMchId;
- return this;
- }
-
- public Builder nonceStr(String nonceStr) {
- this.nonceStr = nonceStr;
- return this;
- }
-
- public Builder sign(String sign) {
- this.sign = sign;
- return this;
- }
-
- public Builder deviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- return this;
- }
-
- public Builder body(String body) {
- this.body = body;
- return this;
- }
-
- public Builder detail(String detail) {
- this.detail = detail;
- return this;
- }
-
- public Builder attach(String attach) {
- this.attach = attach;
- return this;
- }
-
- public Builder outTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- return this;
- }
-
- public Builder feeType(String feeType) {
- this.feeType = feeType;
- return this;
- }
-
- public Builder totalFee(Integer totalFee) {
- this.totalFee = totalFee;
- return this;
- }
-
- public Builder spbillCreateIp(String spbillCreateIp) {
- this.spbillCreateIp = spbillCreateIp;
- return this;
- }
-
- public Builder timeStart(String timeStart) {
- this.timeStart = timeStart;
- return this;
- }
-
- public Builder timeExpire(String timeExpire) {
- this.timeExpire = timeExpire;
- return this;
- }
-
- public Builder goodsTag(String goodsTag) {
- this.goodsTag = goodsTag;
- return this;
- }
-
- public Builder notifyURL(String notifyURL) {
- this.notifyURL = notifyURL;
- return this;
- }
-
- public Builder tradeType(String tradeType) {
- this.tradeType = tradeType;
- return this;
- }
-
- public Builder productId(String productId) {
- this.productId = productId;
- return this;
- }
-
- public Builder limitPay(String limitPay) {
- this.limitPay = limitPay;
- return this;
- }
-
- public Builder openid(String openid) {
- this.openid = openid;
- return this;
- }
-
- public Builder subOpenid(String subOpenid) {
- this.subOpenid = subOpenid;
- return this;
- }
-
- public Builder sceneInfo(String sceneInfo) {
- this.sceneInfo = sceneInfo;
- return this;
- }
-
- public Builder fingerprint(String fingerprint) {
- this.fingerprint = fingerprint;
- return this;
- }
-
- public WxPayUnifiedOrderRequest build() {
- return new WxPayUnifiedOrderRequest(this);
- }
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxEntPayQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxEntPayQueryResult.java
index dac69e17c4..b5a0e04345 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxEntPayQueryResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxEntPayQueryResult.java
@@ -1,13 +1,19 @@
package com.github.binarywang.wxpay.bean.result;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
/**
* 企业付款查询返回结果
* Created by Binary Wang on 2016/10/19.
*
- * @author binarywang (https://github.com/binarywang)
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxEntPayQueryResult extends WxPayBaseResult {
@@ -65,75 +71,4 @@ public class WxEntPayQueryResult extends WxPayBaseResult {
@XStreamAlias("desc")
private String desc;
- public String getPartnerTradeNo() {
- return this.partnerTradeNo;
- }
-
- public void setPartnerTradeNo(String partnerTradeNo) {
- this.partnerTradeNo = partnerTradeNo;
- }
-
- public String getDetailId() {
- return this.detailId;
- }
-
- public void setDetailId(String detailId) {
- this.detailId = detailId;
- }
-
- public String getStatus() {
- return this.status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public String getReason() {
- return this.reason;
- }
-
- public void setReason(String reason) {
- this.reason = reason;
- }
-
- public String getOpenid() {
- return this.openid;
- }
-
- public void setOpenid(String openid) {
- this.openid = openid;
- }
-
- public String getTransferName() {
- return this.transferName;
- }
-
- public void setTransferName(String transferName) {
- this.transferName = transferName;
- }
-
- public Integer getPaymentAmount() {
- return this.paymentAmount;
- }
-
- public void setPaymentAmount(Integer paymentAmount) {
- this.paymentAmount = paymentAmount;
- }
-
- public String getTransferTime() {
- return this.transferTime;
- }
-
- public void setTransferTime(String transferTime) {
- this.transferTime = transferTime;
- }
-
- public String getDesc() {
- return this.desc;
- }
-
- public void setDesc(String desc) {
- this.desc = desc;
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxEntPayResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxEntPayResult.java
index fa0a4e5fdc..033f6e9639 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxEntPayResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxEntPayResult.java
@@ -1,13 +1,19 @@
package com.github.binarywang.wxpay.bean.result;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
/**
* 企业付款返回结果
* Created by Binary Wang on 2016/10/02.
*
- * @author binarywang (https://github.com/binarywang)
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxEntPayResult extends WxPayBaseResult {
@@ -42,43 +48,4 @@ public class WxEntPayResult extends WxPayBaseResult {
@XStreamAlias("payment_time")
private String paymentTime;
- public String getMchAppid() {
- return this.mchAppid;
- }
-
- public void setMchAppid(String mchAppid) {
- this.mchAppid = mchAppid;
- }
-
- public String getDeviceInfo() {
- return this.deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getPartnerTradeNo() {
- return this.partnerTradeNo;
- }
-
- public void setPartnerTradeNo(String partnerTradeNo) {
- this.partnerTradeNo = partnerTradeNo;
- }
-
- public String getPaymentNo() {
- return this.paymentNo;
- }
-
- public void setPaymentNo(String paymentNo) {
- this.paymentNo = paymentNo;
- }
-
- public String getPaymentTime() {
- return this.paymentTime;
- }
-
- public void setPaymentTime(String paymentTime) {
- this.paymentTime = paymentTime;
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayAuthcode2OpenidResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayAuthcode2OpenidResult.java
index f56c61a77f..3f1d53a78e 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayAuthcode2OpenidResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayAuthcode2OpenidResult.java
@@ -1,14 +1,21 @@
package com.github.binarywang.wxpay.bean.result;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
/**
*
* 授权码查询openid接口请求结果类
* Created by Binary Wang on 2017-3-27.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxPayAuthcode2OpenidResult extends WxPayBaseResult {
/**
@@ -23,18 +30,4 @@ public class WxPayAuthcode2OpenidResult extends WxPayBaseResult {
@XStreamAlias("openid")
private String openid;
- public WxPayAuthcode2OpenidResult() {
- }
-
- public WxPayAuthcode2OpenidResult(String openid) {
- this.openid = openid;
- }
-
- public String getOpenid() {
- return this.openid;
- }
-
- public void setOpenid(String openid) {
- this.openid = openid;
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java
index d4b96dc408..1e0527ebda 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java
@@ -4,9 +4,11 @@
import com.github.binarywang.wxpay.service.impl.WxPayServiceAbstractImpl;
import com.github.binarywang.wxpay.util.SignUtils;
import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
import me.chanjar.weixin.common.util.ToStringUtils;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
import org.apache.commons.lang3.StringUtils;
@@ -24,15 +26,18 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.math.BigDecimal;
+import java.util.List;
import java.util.Map;
/**
*
* 微信支付结果共用属性类
* Created by Binary Wang on 2016-10-24.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
public abstract class WxPayBaseResult {
/**
* 返回状态码
@@ -124,14 +129,6 @@ public static T fromXML(String xmlString, Class c
return result;
}
- public String getXmlString() {
- return this.xmlString;
- }
-
- public void setXmlString(String xmlString) {
- this.xmlString = xmlString;
- }
-
protected Logger getLogger() {
return LoggerFactory.getLogger(this.getClass());
}
@@ -141,94 +138,6 @@ public String toString() {
return ToStringUtils.toSimpleString(this);
}
- public String getReturnCode() {
- return this.returnCode;
- }
-
- public void setReturnCode(String returnCode) {
- this.returnCode = returnCode;
- }
-
- public String getReturnMsg() {
- return this.returnMsg;
- }
-
- public void setReturnMsg(String returnMsg) {
- this.returnMsg = returnMsg;
- }
-
- public String getResultCode() {
- return this.resultCode;
- }
-
- public void setResultCode(String resultCode) {
- this.resultCode = resultCode;
- }
-
- public String getErrCode() {
- return this.errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-
- public String getErrCodeDes() {
- return this.errCodeDes;
- }
-
- public void setErrCodeDes(String errCodeDes) {
- this.errCodeDes = errCodeDes;
- }
-
- public String getAppid() {
- return this.appid;
- }
-
- public void setAppid(String appid) {
- this.appid = appid;
- }
-
- public String getMchId() {
- return this.mchId;
- }
-
- public void setMchId(String mchId) {
- this.mchId = mchId;
- }
-
- public String getNonceStr() {
- return this.nonceStr;
- }
-
- public void setNonceStr(String nonceStr) {
- this.nonceStr = nonceStr;
- }
-
- public String getSign() {
- return this.sign;
- }
-
- public void setSign(String sign) {
- this.sign = sign;
- }
-
- public String getSubAppId() {
- return subAppId;
- }
-
- public void setSubAppId(String subAppId) {
- this.subAppId = subAppId;
- }
-
- public String getSubMchId() {
- return subMchId;
- }
-
- public void setSubMchId(String subMchId) {
- this.subMchId = subMchId;
- }
-
/**
* 将bean通过保存的xml字符串转换成map
*/
@@ -306,37 +215,43 @@ protected Integer getXmlValueAsInt(String... path) {
/**
* 校验返回结果签名
+ *
+ * @param signType 签名类型
+ * @param checkSuccess 是否同时检查结果是否成功
*/
- public void checkResult(WxPayServiceAbstractImpl wxPayService) throws WxPayException {
+ public void checkResult(WxPayServiceAbstractImpl wxPayService, String signType, boolean checkSuccess) throws WxPayException {
//校验返回结果签名
Map map = toMap();
- if (getSign() != null && !SignUtils.checkSign(map, wxPayService.getConfig().getMchKey())) {
+ if (getSign() != null && !SignUtils.checkSign(map, signType, wxPayService.getConfig().getMchKey())) {
this.getLogger().debug("校验结果签名失败,参数:{}", map);
throw new WxPayException("参数格式校验错误!");
}
//校验结果是否成功
- if (!StringUtils.equalsAny(StringUtils.trimToEmpty(getReturnCode()).toUpperCase(), "SUCCESS", "")
- || !StringUtils.equalsAny(StringUtils.trimToEmpty(getResultCode()).toUpperCase(), "SUCCESS", "")) {
- StringBuilder errorMsg = new StringBuilder();
- if (getReturnCode() != null) {
- errorMsg.append("返回代码:").append(getReturnCode());
- }
- if (getReturnMsg() != null) {
- errorMsg.append(",返回信息:").append(getReturnMsg());
- }
- if (getResultCode() != null) {
- errorMsg.append(",结果代码:").append(getResultCode());
+ if (checkSuccess) {
+ List successStrings = Lists.newArrayList("SUCCESS", "");
+ if (!successStrings.contains(StringUtils.trimToEmpty(getReturnCode()).toUpperCase())
+ || !successStrings.contains(StringUtils.trimToEmpty(getResultCode()).toUpperCase())) {
+ StringBuilder errorMsg = new StringBuilder();
+ if (getReturnCode() != null) {
+ errorMsg.append("返回代码:").append(getReturnCode());
+ }
+ if (getReturnMsg() != null) {
+ errorMsg.append(",返回信息:").append(getReturnMsg());
+ }
+ if (getResultCode() != null) {
+ errorMsg.append(",结果代码:").append(getResultCode());
+ }
+ if (getErrCode() != null) {
+ errorMsg.append(",错误代码:").append(getErrCode());
+ }
+ if (getErrCodeDes() != null) {
+ errorMsg.append(",错误详情:").append(getErrCodeDes());
+ }
+
+ this.getLogger().error("\n结果业务代码异常,返回结果:{},\n{}", map, errorMsg.toString());
+ throw WxPayException.from(this);
}
- if (getErrCode() != null) {
- errorMsg.append(",错误代码:").append(getErrCode());
- }
- if (getErrCodeDes() != null) {
- errorMsg.append(",错误详情:").append(getErrCodeDes());
- }
-
- this.getLogger().error("\n结果业务代码异常,返回結果:{},\n{}", map, errorMsg.toString());
- throw WxPayException.from(this);
}
}
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillBaseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillBaseResult.java
index e469ff4538..28ed6e7f18 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillBaseResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillBaseResult.java
@@ -1,14 +1,26 @@
package com.github.binarywang.wxpay.bean.result;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import me.chanjar.weixin.common.util.ToStringUtils;
+
import java.io.Serializable;
+/**
+ * 交易时间:2017-04-06 01:00:02 公众账号ID: 商户号: 子商户号:0 设备号:WEB 微信订单号: 商户订单号:2017040519091071873216 用户标识: 交易类型:NATIVE
+ * 交易状态:REFUND 付款银行:CFT 货币种类:CNY 总金额:0.00 企业红包金额:0.00 微信退款单号: 商户退款单号:20170406010000933 退款金额:0.01 企业红包退款金额:0.00
+ * 退款类型:ORIGINAL 退款状态:SUCCESS 商品名称: 商户数据包: 手续费:0.00000 费率 :0.60%
+ */
+@Data
+@NoArgsConstructor
public class WxPayBillBaseResult implements Serializable {
- /*
- * 交易时间:2017-04-06 01:00:02 公众账号ID: 商户号: 子商户号:0 设备号:WEB 微信订单号: 商户订单号:2017040519091071873216 用户标识: 交易类型:NATIVE
- * 交易状态:REFUND 付款银行:CFT 货币种类:CNY 总金额:0.00 企业红包金额:0.00 微信退款单号: 商户退款单号:20170406010000933 退款金额:0.01 企业红包退款金额:0.00
- * 退款类型:ORIGINAL 退款状态:SUCCESS 商品名称: 商户数据包: 手续费:0.00000 费率 :0.60%
- */
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 2226245109137435453L;
+
+ @Override
+ public String toString() {
+ return ToStringUtils.toSimpleString(this);
+ }
+
/**
* 交易时间
*/
@@ -32,7 +44,7 @@ public class WxPayBillBaseResult implements Serializable {
/**
* 微信订单号
*/
- private String transationId;
+ private String transactionId;
/**
* 商户订单号
*/
@@ -106,200 +118,4 @@ public class WxPayBillBaseResult implements Serializable {
*/
private String poundageRate;
- public static long getSerialversionuid() {
- return serialVersionUID;
- }
-
- public String getTradeTime() {
- return tradeTime;
- }
-
- public void setTradeTime(String tradeTime) {
- this.tradeTime = tradeTime;
- }
-
- public String getAppId() {
- return appId;
- }
-
- public void setAppId(String appId) {
- this.appId = appId;
- }
-
- public String getMchId() {
- return mchId;
- }
-
- public void setMchId(String mchId) {
- this.mchId = mchId;
- }
-
- public String getSubMchId() {
- return subMchId;
- }
-
- public void setSubMchId(String subMchId) {
- this.subMchId = subMchId;
- }
-
- public String getDeviceInfo() {
- return deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getTransationId() {
- return transationId;
- }
-
- public void setTransationId(String transationId) {
- this.transationId = transationId;
- }
-
- public String getOutTradeNo() {
- return outTradeNo;
- }
-
- public void setOutTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- }
-
- public String getOpenId() {
- return openId;
- }
-
- public void setOpenId(String openId) {
- this.openId = openId;
- }
-
- public String getTradeType() {
- return tradeType;
- }
-
- public void setTradeType(String tradeType) {
- this.tradeType = tradeType;
- }
-
- public String getTradeState() {
- return tradeState;
- }
-
- public void setTradeState(String tradeState) {
- this.tradeState = tradeState;
- }
-
- public String getBankType() {
- return bankType;
- }
-
- public void setBankType(String bankType) {
- this.bankType = bankType;
- }
-
- public String getFeeType() {
- return feeType;
- }
-
- public void setFeeType(String feeType) {
- this.feeType = feeType;
- }
-
- public String getTotalFee() {
- return totalFee;
- }
-
- public void setTotalFee(String totalFee) {
- this.totalFee = totalFee;
- }
-
- public String getCouponFee() {
- return couponFee;
- }
-
- public void setCouponFee(String couponFee) {
- this.couponFee = couponFee;
- }
-
- public String getRefundId() {
- return refundId;
- }
-
- public void setRefundId(String refundId) {
- this.refundId = refundId;
- }
-
- public String getOutRefundNo() {
- return outRefundNo;
- }
-
- public void setOutRefundNo(String outRefundNo) {
- this.outRefundNo = outRefundNo;
- }
-
- public String getSettlementRefundFee() {
- return settlementRefundFee;
- }
-
- public void setSettlementRefundFee(String settlementRefundFee) {
- this.settlementRefundFee = settlementRefundFee;
- }
-
- public String getCouponRefundFee() {
- return couponRefundFee;
- }
-
- public void setCouponRefundFee(String couponRefundFee) {
- this.couponRefundFee = couponRefundFee;
- }
-
- public String getRefundChannel() {
- return refundChannel;
- }
-
- public void setRefundChannel(String refundChannel) {
- this.refundChannel = refundChannel;
- }
-
- public String getRefundState() {
- return refundState;
- }
-
- public void setRefundState(String refundState) {
- this.refundState = refundState;
- }
-
- public String getBody() {
- return body;
- }
-
- public void setBody(String body) {
- this.body = body;
- }
-
- public String getAttach() {
- return attach;
- }
-
- public void setAttach(String attach) {
- this.attach = attach;
- }
-
- public String getPoundage() {
- return poundage;
- }
-
- public void setPoundage(String poundage) {
- this.poundage = poundage;
- }
-
- public String getPoundageRate() {
- return poundageRate;
- }
-
- public void setPoundageRate(String poundageRate) {
- this.poundageRate = poundageRate;
- }
-
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillResult.java
index a7fb25bef2..0a1a4b2583 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillResult.java
@@ -1,14 +1,25 @@
package com.github.binarywang.wxpay.bean.result;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import me.chanjar.weixin.common.util.ToStringUtils;
+
import java.io.Serializable;
import java.util.List;
+@Data
+@NoArgsConstructor
public class WxPayBillResult implements Serializable {
+ private static final long serialVersionUID = -7687458652694204070L;
+
+ @Override
+ public String toString() {
+ return ToStringUtils.toSimpleString(this);
+ }
+
/**
* 对账返回对象
*/
- private static final long serialVersionUID = 1L;
-
private List wxPayBillBaseResultLst;
/**
* 总交易单数
@@ -31,53 +42,4 @@ public class WxPayBillResult implements Serializable {
*/
private String totalPoundageFee;
- public List getWxPayBillBaseResultLst() {
- return wxPayBillBaseResultLst;
- }
-
- public void setWxPayBillBaseResultLst(List wxPayBillBaseResultLst) {
- this.wxPayBillBaseResultLst = wxPayBillBaseResultLst;
- }
-
- public String getTotalRecord() {
- return totalRecord;
- }
-
- public void setTotalRecord(String totalRecord) {
- this.totalRecord = totalRecord;
- }
-
- public String getTotalFee() {
- return totalFee;
- }
-
- public void setTotalFee(String totalFee) {
- this.totalFee = totalFee;
- }
-
- public String getTotalRefundFee() {
- return totalRefundFee;
- }
-
- public void setTotalRefundFee(String totalRefundFee) {
- this.totalRefundFee = totalRefundFee;
- }
-
- public String getTotalCouponFee() {
- return totalCouponFee;
- }
-
- public void setTotalCouponFee(String totalCouponFee) {
- this.totalCouponFee = totalCouponFee;
- }
-
- public String getTotalPoundageFee() {
- return totalPoundageFee;
- }
-
- public void setTotalPoundageFee(String totalPoundageFee) {
- this.totalPoundageFee = totalPoundageFee;
- }
-
-
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayCommonResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayCommonResult.java
index 1fc4d30940..8c99c9df37 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayCommonResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayCommonResult.java
@@ -6,8 +6,9 @@
*
* 微信支付结果仅包含有return 和result等相关信息的的属性类
* Created by Binary Wang on 2017-01-09.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
@XStreamAlias("xml")
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayMicropayResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayMicropayResult.java
index 2f8842af82..4f6b04cf3c 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayMicropayResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayMicropayResult.java
@@ -1,14 +1,21 @@
package com.github.binarywang.wxpay.bean.result;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
/**
*
* 提交刷卡支付接口响应结果对象类
* Created by Binary Wang on 2017-3-23.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxPayMicropayResult extends WxPayBaseResult {
/**
@@ -206,123 +213,4 @@ public class WxPayMicropayResult extends WxPayBaseResult {
@XStreamAlias("promotion_detail")
private String promotionDetail;
- public String getOpenid() {
- return this.openid;
- }
-
- public void setOpenid(String openid) {
- this.openid = openid;
- }
-
- public String getIsSubscribe() {
- return this.isSubscribe;
- }
-
- public void setIsSubscribe(String isSubscribe) {
- this.isSubscribe = isSubscribe;
- }
-
- public String getTradeType() {
- return this.tradeType;
- }
-
- public void setTradeType(String tradeType) {
- this.tradeType = tradeType;
- }
-
- public String getBankType() {
- return this.bankType;
- }
-
- public void setBankType(String bankType) {
- this.bankType = bankType;
- }
-
- public String getFeeType() {
- return this.feeType;
- }
-
- public void setFeeType(String feeType) {
- this.feeType = feeType;
- }
-
- public String getTotalFee() {
- return this.totalFee;
- }
-
- public void setTotalFee(String totalFee) {
- this.totalFee = totalFee;
- }
-
- public Integer getSettlementTotalFee() {
- return this.settlementTotalFee;
- }
-
- public void setSettlementTotalFee(Integer settlementTotalFee) {
- this.settlementTotalFee = settlementTotalFee;
- }
-
- public Integer getCouponFee() {
- return this.couponFee;
- }
-
- public void setCouponFee(Integer couponFee) {
- this.couponFee = couponFee;
- }
-
- public String getCashFeeType() {
- return this.cashFeeType;
- }
-
- public void setCashFeeType(String cashFeeType) {
- this.cashFeeType = cashFeeType;
- }
-
- public Integer getCashFee() {
- return this.cashFee;
- }
-
- public void setCashFee(Integer cashFee) {
- this.cashFee = cashFee;
- }
-
- public String getTransactionId() {
- return this.transactionId;
- }
-
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
- }
-
- public String getOutTradeNo() {
- return this.outTradeNo;
- }
-
- public void setOutTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- }
-
- public String getAttach() {
- return this.attach;
- }
-
- public void setAttach(String attach) {
- this.attach = attach;
- }
-
- public String getTimeEnd() {
- return this.timeEnd;
- }
-
- public void setTimeEnd(String timeEnd) {
- this.timeEnd = timeEnd;
- }
-
- public String getPromotionDetail() {
- return this.promotionDetail;
- }
-
- public void setPromotionDetail(String promotionDetail) {
- this.promotionDetail = promotionDetail;
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderCloseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderCloseResult.java
index 7221251f10..5451c8535d 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderCloseResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderCloseResult.java
@@ -1,14 +1,21 @@
package com.github.binarywang.wxpay.bean.result;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
/**
*
* 关闭订单结果对象类
* Created by Binary Wang on 2016-10-27.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxPayOrderCloseResult extends WxPayBaseResult {
@@ -18,11 +25,4 @@ public class WxPayOrderCloseResult extends WxPayBaseResult {
@XStreamAlias("result_msg")
private String resultMsg;
- public String getResultMsg() {
- return this.resultMsg;
- }
-
- public void setResultMsg(String resultMsg) {
- this.resultMsg = resultMsg;
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderQueryResult.java
index ff087bf010..9da15f5a6f 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderQueryResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderQueryResult.java
@@ -2,6 +2,7 @@
import com.google.common.collect.Lists;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
import java.util.List;
@@ -18,8 +19,11 @@
* 描述
*
*
- * @author binarywang(Binary Wang)
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxPayOrderQueryResult extends WxPayBaseResult {
@@ -236,158 +240,6 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
@XStreamAlias("trade_state_desc")
private String tradeStateDesc;
- public String getDeviceInfo() {
- return this.deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getOpenid() {
- return this.openid;
- }
-
- public void setOpenid(String openid) {
- this.openid = openid;
- }
-
- public String getIsSubscribe() {
- return this.isSubscribe;
- }
-
- public void setIsSubscribe(String isSubscribe) {
- this.isSubscribe = isSubscribe;
- }
-
- public String getTradeType() {
- return this.tradeType;
- }
-
- public void setTradeType(String tradeType) {
- this.tradeType = tradeType;
- }
-
- public String getTradeState() {
- return this.tradeState;
- }
-
- public void setTradeState(String tradeState) {
- this.tradeState = tradeState;
- }
-
- public String getBankType() {
- return this.bankType;
- }
-
- public void setBankType(String bankType) {
- this.bankType = bankType;
- }
-
- public Integer getTotalFee() {
- return this.totalFee;
- }
-
- public void setTotalFee(Integer totalFee) {
- this.totalFee = totalFee;
- }
-
- public Integer getSettlementTotalFee() {
- return this.settlementTotalFee;
- }
-
- public void setSettlementTotalFee(Integer settlementTotalFee) {
- this.settlementTotalFee = settlementTotalFee;
- }
-
- public String getFeeType() {
- return this.feeType;
- }
-
- public void setFeeType(String feeType) {
- this.feeType = feeType;
- }
-
- public Integer getCashFee() {
- return this.cashFee;
- }
-
- public void setCashFee(Integer cashFee) {
- this.cashFee = cashFee;
- }
-
- public String getCashFeeType() {
- return this.cashFeeType;
- }
-
- public void setCashFeeType(String cashFeeType) {
- this.cashFeeType = cashFeeType;
- }
-
- public Integer getCouponFee() {
- return this.couponFee;
- }
-
- public void setCouponFee(Integer couponFee) {
- this.couponFee = couponFee;
- }
-
- public Integer getCouponCount() {
- return this.couponCount;
- }
-
- public void setCouponCount(Integer couponCount) {
- this.couponCount = couponCount;
- }
-
- public List代金券类型
@@ -438,35 +293,5 @@ public static class Coupon {
*/
private Integer couponFee;
- public Coupon(String couponType, String couponId, Integer couponFee) {
- this.couponType = couponType;
- this.couponId = couponId;
- this.couponFee = couponFee;
- }
-
- public String getCouponType() {
- return this.couponType;
- }
-
- public void setCouponType(String couponType) {
- this.couponType = couponType;
- }
-
- public String getCouponId() {
- return this.couponId;
- }
-
- public void setCouponId(String couponId) {
- this.couponId = couponId;
- }
-
- public Integer getCouponFee() {
- return this.couponFee;
- }
-
- public void setCouponFee(Integer couponFee) {
- this.couponFee = couponFee;
- }
-
}
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderReverseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderReverseResult.java
index c80b72d216..bf36764f6e 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderReverseResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderReverseResult.java
@@ -1,14 +1,21 @@
package com.github.binarywang.wxpay.bean.result;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
/**
*
* 撤销订单响应结果类
* Created by Binary Wang on 2017-3-23.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxPayOrderReverseResult extends WxPayBaseResult {
@@ -25,11 +32,4 @@ public class WxPayOrderReverseResult extends WxPayBaseResult {
@XStreamAlias("recall")
private String isRecall;
- public String getIsRecall() {
- return this.isRecall;
- }
-
- public void setIsRecall(String isRecall) {
- this.isRecall = isRecall;
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRedpackQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRedpackQueryResult.java
index e0b86732fd..84030f172f 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRedpackQueryResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRedpackQueryResult.java
@@ -1,6 +1,9 @@
package com.github.binarywang.wxpay.bean.result;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
/**
*
@@ -12,9 +15,13 @@
* 类型
* 说明
* Created by Binary Wang on 2016-11-28.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxPayRedpackQueryResult extends WxPayBaseResult {
@@ -259,148 +266,4 @@ public class WxPayRedpackQueryResult extends WxPayBaseResult {
*/
@XStreamAlias("rcv_time")
private String receiveTime;
-
- public String getMchBillNo() {
- return mchBillNo;
- }
-
- public void setMchBillNo(String mchBillNo) {
- this.mchBillNo = mchBillNo;
- }
-
- public String getDetailId() {
- return detailId;
- }
-
- public void setDetailId(String detailId) {
- this.detailId = detailId;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public String getSendType() {
- return sendType;
- }
-
- public void setSendType(String sendType) {
- this.sendType = sendType;
- }
-
- public String getHbType() {
- return hbType;
- }
-
- public void setHbType(String hbType) {
- this.hbType = hbType;
- }
-
- public Integer getTotalNum() {
- return totalNum;
- }
-
- public void setTotalNum(Integer totalNum) {
- this.totalNum = totalNum;
- }
-
- public Integer getTotalAmount() {
- return totalAmount;
- }
-
- public void setTotalAmount(Integer totalAmount) {
- this.totalAmount = totalAmount;
- }
-
- public String getReason() {
- return reason;
- }
-
- public void setReason(String reason) {
- this.reason = reason;
- }
-
- public String getSendTime() {
- return sendTime;
- }
-
- public void setSendTime(String sendTime) {
- this.sendTime = sendTime;
- }
-
- public String getRefundTime() {
- return refundTime;
- }
-
- public void setRefundTime(String refundTime) {
- this.refundTime = refundTime;
- }
-
- public Integer getRefundAmount() {
- return refundAmount;
- }
-
- public void setRefundAmount(Integer refundAmount) {
- this.refundAmount = refundAmount;
- }
-
- public String getWishing() {
- return wishing;
- }
-
- public void setWishing(String wishing) {
- this.wishing = wishing;
- }
-
- public String getRemark() {
- return remark;
- }
-
- public void setRemark(String remark) {
- this.remark = remark;
- }
-
- public String getActName() {
- return actName;
- }
-
- public void setActName(String actName) {
- this.actName = actName;
- }
-
- public String getHblist() {
- return hblist;
- }
-
- public void setHblist(String hblist) {
- this.hblist = hblist;
- }
-
- public String getOpenid() {
- return openid;
- }
-
- public void setOpenid(String openid) {
- this.openid = openid;
- }
-
- public Integer getAmount() {
- return amount;
- }
-
- public void setAmount(Integer amount) {
- this.amount = amount;
- }
-
- public String getReceiveTime() {
- return receiveTime;
- }
-
- public void setReceiveTime(String receiveTime) {
- this.receiveTime = receiveTime;
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundQueryResult.java
index 1916fdb9e7..f97336015a 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundQueryResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundQueryResult.java
@@ -2,15 +2,20 @@
import com.google.common.collect.Lists;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.*;
import java.util.List;
/**
*
* Created by Binary Wang on 2016-11-24.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxPayRefundQueryResult extends WxPayBaseResult {
/**
@@ -111,78 +116,6 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
private List refundRecords;
- public String getDeviceInfo() {
- return deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getTransactionId() {
- return transactionId;
- }
-
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
- }
-
- public String getOutTradeNo() {
- return outTradeNo;
- }
-
- public void setOutTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- }
-
- public Integer getTotalFee() {
- return totalFee;
- }
-
- public void setTotalFee(Integer totalFee) {
- this.totalFee = totalFee;
- }
-
- public Integer getSettlementTotalFee() {
- return settlementTotalFee;
- }
-
- public void setSettlementTotalFee(Integer settlementTotalFee) {
- this.settlementTotalFee = settlementTotalFee;
- }
-
- public String getFeeType() {
- return feeType;
- }
-
- public void setFeeType(String feeType) {
- this.feeType = feeType;
- }
-
- public Integer getCashFee() {
- return cashFee;
- }
-
- public void setCashFee(Integer cashFee) {
- this.cashFee = cashFee;
- }
-
- public Integer getRefundCount() {
- return refundCount;
- }
-
- public void setRefundCount(Integer refundCount) {
- this.refundCount = refundCount;
- }
-
- public List getRefundRecords() {
- return refundRecords;
- }
-
- public void setRefundRecords(List refundRecords) {
- this.refundRecords = refundRecords;
- }
-
/**
* 组装生成退款记录属性的内容
*/
@@ -203,7 +136,7 @@ public void composeRefundRecords() {
refundRecord.setCouponRefundFee(this.getXmlValueAsInt("xml/coupon_refund_fee_" + i));
refundRecord.setCouponRefundCount(this.getXmlValueAsInt("xml/coupon_refund_count_" + i));
refundRecord.setRefundStatus(this.getXmlValue("xml/refund_status_" + i));
- refundRecord.setRefundRecvAccout(this.getXmlValue("xml/refund_recv_accout_" + i));
+ refundRecord.setRefundRecvAccount(this.getXmlValue("xml/refund_recv_accout_" + i));
if (refundRecord.getCouponRefundCount() == null || refundRecord.getCouponRefundCount() == 0) {
continue;
@@ -223,6 +156,10 @@ public void composeRefundRecords() {
}
}
+ @Data
+ @Builder(builderMethodName = "newBuilder")
+ @NoArgsConstructor
+ @AllArgsConstructor
public static class RefundRecord {
/**
*
@@ -371,104 +308,10 @@ public static class RefundRecord {
*
*/
@XStreamAlias("refund_recv_accout")
- private String refundRecvAccout;
-
- public String getOutRefundNo() {
- return outRefundNo;
- }
-
- public void setOutRefundNo(String outRefundNo) {
- this.outRefundNo = outRefundNo;
- }
-
- public String getRefundId() {
- return refundId;
- }
-
- public void setRefundId(String refundId) {
- this.refundId = refundId;
- }
-
- public String getRefundChannel() {
- return refundChannel;
- }
-
- public void setRefundChannel(String refundChannel) {
- this.refundChannel = refundChannel;
- }
-
- public Integer getRefundFee() {
- return refundFee;
- }
-
- public void setRefundFee(Integer refundFee) {
- this.refundFee = refundFee;
- }
-
- public Integer getSettlementRefundFee() {
- return settlementRefundFee;
- }
-
- public void setSettlementRefundFee(Integer settlementRefundFee) {
- this.settlementRefundFee = settlementRefundFee;
- }
-
- public String getRefundAccount() {
- return refundAccount;
- }
-
- public void setRefundAccount(String refundAccount) {
- this.refundAccount = refundAccount;
- }
-
- public String getCouponType() {
- return couponType;
- }
-
- public void setCouponType(String couponType) {
- this.couponType = couponType;
- }
-
- public Integer getCouponRefundFee() {
- return couponRefundFee;
- }
-
- public void setCouponRefundFee(Integer couponRefundFee) {
- this.couponRefundFee = couponRefundFee;
- }
-
- public Integer getCouponRefundCount() {
- return couponRefundCount;
- }
-
- public void setCouponRefundCount(Integer couponRefundCount) {
- this.couponRefundCount = couponRefundCount;
- }
-
- public List getRefundCoupons() {
- return refundCoupons;
- }
-
- public void setRefundCoupons(List refundCoupons) {
- this.refundCoupons = refundCoupons;
- }
-
- public String getRefundStatus() {
- return refundStatus;
- }
-
- public void setRefundStatus(String refundStatus) {
- this.refundStatus = refundStatus;
- }
-
- public String getRefundRecvAccout() {
- return refundRecvAccout;
- }
-
- public void setRefundRecvAccout(String refundRecvAccout) {
- this.refundRecvAccout = refundRecvAccout;
- }
+ private String refundRecvAccount;
+ @Data
+ @NoArgsConstructor
public static class RefundCoupon {
/**
*
@@ -516,12 +359,6 @@ public RefundCoupon(String couponRefundId, Integer couponRefundFee) {
this.couponRefundFee = couponRefundFee;
}
- @Deprecated
- public RefundCoupon(String couponRefundBatchId, String couponRefundId, Integer couponRefundFee) {
- this.couponRefundBatchId = couponRefundBatchId;
- this.couponRefundId = couponRefundId;
- this.couponRefundFee = couponRefundFee;
- }
}
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundResult.java
index 1e6126b210..2da31a3798 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundResult.java
@@ -1,6 +1,9 @@
package com.github.binarywang.wxpay.bean.result;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
import java.io.Serializable;
@@ -12,6 +15,9 @@
*
* @author liukaitj
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxPayRefundResult extends WxPayBaseResult implements Serializable {
private static final long serialVersionUID = 1L;
@@ -58,116 +64,4 @@ public class WxPayRefundResult extends WxPayBaseResult implements Serializable {
@XStreamAlias("coupon_refund_id")
private String couponRefundId;
- public String getDeviceInfo() {
- return this.deviceInfo;
- }
-
- public void setDeviceInfo(String deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- public String getTransactionId() {
- return this.transactionId;
- }
-
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
- }
-
- public String getOutTradeNo() {
- return this.outTradeNo;
- }
-
- public void setOutTradeNo(String outTradeNo) {
- this.outTradeNo = outTradeNo;
- }
-
- public String getOutRefundNo() {
- return this.outRefundNo;
- }
-
- public void setOutRefundNo(String outRefundNo) {
- this.outRefundNo = outRefundNo;
- }
-
- public String getRefundId() {
- return this.refundId;
- }
-
- public void setRefundId(String refundId) {
- this.refundId = refundId;
- }
-
- public String getRefundChannel() {
- return this.refundChannel;
- }
-
- public void setRefundChannel(String refundChannel) {
- this.refundChannel = refundChannel;
- }
-
- public String getRefundFee() {
- return this.refundFee;
- }
-
- public void setRefundFee(String refundFee) {
- this.refundFee = refundFee;
- }
-
- public String getTotalFee() {
- return this.totalFee;
- }
-
- public void setTotalFee(String totalFee) {
- this.totalFee = totalFee;
- }
-
- public String getFeeType() {
- return this.feeType;
- }
-
- public void setFeeType(String feeType) {
- this.feeType = feeType;
- }
-
- public String getCashFee() {
- return this.cashFee;
- }
-
- public void setCashFee(String cashFee) {
- this.cashFee = cashFee;
- }
-
- public String getCashRefundFee() {
- return this.cashRefundFee;
- }
-
- public void setCashRefundFee(String cashRefundFee) {
- this.cashRefundFee = cashRefundFee;
- }
-
- public String getCouponRefundFee() {
- return this.couponRefundFee;
- }
-
- public void setCouponRefundFee(String couponRefundFee) {
- this.couponRefundFee = couponRefundFee;
- }
-
- public String getCouponRefundCount() {
- return this.couponRefundCount;
- }
-
- public void setCouponRefundCount(String couponRefundCount) {
- this.couponRefundCount = couponRefundCount;
- }
-
- public String getCouponRefundId() {
- return this.couponRefundId;
- }
-
- public void setCouponRefundId(String couponRefundId) {
- this.couponRefundId = couponRefundId;
- }
-
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPaySandboxSignKeyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPaySandboxSignKeyResult.java
index 6326f694d3..792e00fdeb 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPaySandboxSignKeyResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPaySandboxSignKeyResult.java
@@ -1,6 +1,9 @@
package com.github.binarywang.wxpay.bean.result;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
/**
*
@@ -9,6 +12,9 @@
*
* @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxPaySandboxSignKeyResult extends WxPayBaseResult {
@@ -25,11 +31,4 @@ public class WxPaySandboxSignKeyResult extends WxPayBaseResult {
@XStreamAlias("sandbox_signkey")
private String sandboxSignKey;
- public String getSandboxSignKey() {
- return sandboxSignKey;
- }
-
- public void setSandboxSignKey(String sandboxSignKey) {
- this.sandboxSignKey = sandboxSignKey;
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPaySendRedpackResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPaySendRedpackResult.java
index 868f089b74..560721f5a8 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPaySendRedpackResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPaySendRedpackResult.java
@@ -1,6 +1,9 @@
package com.github.binarywang.wxpay.bean.result;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
import java.io.Serializable;
@@ -10,6 +13,9 @@
*
* @author kane
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxPaySendRedpackResult extends WxPayBaseResult implements Serializable {
private static final long serialVersionUID = -4837415036337132073L;
@@ -32,51 +38,4 @@ public class WxPaySendRedpackResult extends WxPayBaseResult implements Serializa
@XStreamAlias("send_listid")
private String sendListid;
- public String getMchBillno() {
- return this.mchBillno;
- }
-
- public void setMchBillno(String mchBillno) {
- this.mchBillno = mchBillno;
- }
-
- public String getWxappid() {
- return this.wxappid;
- }
-
- public void setWxappid(String wxappid) {
- this.wxappid = wxappid;
- }
-
- public String getReOpenid() {
- return this.reOpenid;
- }
-
- public void setReOpenid(String reOpenid) {
- this.reOpenid = reOpenid;
- }
-
- public int getTotalAmount() {
- return this.totalAmount;
- }
-
- public void setTotalAmount(int totalAmount) {
- this.totalAmount = totalAmount;
- }
-
- public String getSendTime() {
- return this.sendTime;
- }
-
- public void setSendTime(String sendTime) {
- this.sendTime = sendTime;
- }
-
- public String getSendListid() {
- return this.sendListid;
- }
-
- public void setSendListid(String sendListid) {
- this.sendListid = sendListid;
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayShorturlResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayShorturlResult.java
index 2f93cb81bf..93e74a0cce 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayShorturlResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayShorturlResult.java
@@ -1,14 +1,21 @@
package com.github.binarywang.wxpay.bean.result;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
/**
*
* 转换短链接结果对象类
* Created by Binary Wang on 2017-3-27.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author Binary Wang
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxPayShorturlResult extends WxPayBaseResult {
/**
@@ -24,11 +31,4 @@ public class WxPayShorturlResult extends WxPayBaseResult {
@XStreamAlias("short_url")
private String shortUrl;
- public String getShortUrl() {
- return this.shortUrl;
- }
-
- public void setShortUrl(String shortUrl) {
- this.shortUrl = shortUrl;
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderResult.java
index d8ab2ab6df..4f25421fc2 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderResult.java
@@ -1,6 +1,9 @@
package com.github.binarywang.wxpay.bean.result;
import com.thoughtworks.xstream.annotations.XStreamAlias;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
/**
*
@@ -10,6 +13,9 @@
*
* @author chanjarster
*/
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
@XStreamAlias("xml")
public class WxPayUnifiedOrderResult extends WxPayBaseResult {
@@ -37,35 +43,4 @@ public class WxPayUnifiedOrderResult extends WxPayBaseResult {
@XStreamAlias("code_url")
private String codeURL;
- public String getPrepayId() {
- return this.prepayId;
- }
-
- public void setPrepayId(String prepayId) {
- this.prepayId = prepayId;
- }
-
- public String getTradeType() {
- return this.tradeType;
- }
-
- public void setTradeType(String tradeType) {
- this.tradeType = tradeType;
- }
-
- public String getCodeURL() {
- return this.codeURL;
- }
-
- public void setCodeURL(String codeURL) {
- this.codeURL = codeURL;
- }
-
- public String getMwebUrl() {
- return mwebUrl;
- }
-
- public void setMwebUrl(String mwebUrl) {
- this.mwebUrl = mwebUrl;
- }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java
index 7d8cd5e1e3..684073d0af 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java
@@ -36,6 +36,7 @@ public class WxPayConfig {
private String subMchId;
private String notifyUrl;
private String tradeType;
+ private String signType;
private SSLContext sslContext;
private String keyPath;
private boolean useSandboxEnv = false;
@@ -139,6 +140,19 @@ public void setTradeType(String tradeType) {
this.tradeType = tradeType;
}
+ /**
+ * 签名方式
+ * 有两种HMAC_SHA256 和MD5
+ * @see com.github.binarywang.wxpay.constant.WxPayConstants.SignType
+ */
+ public String getSignType() {
+ return this.signType;
+ }
+
+ public void setSignType(String signType) {
+ this.signType = signType;
+ }
+
public SSLContext getSslContext() {
return this.sslContext;
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java
index 47f636d0fc..8e9eea95fc 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java
@@ -1,6 +1,9 @@
package com.github.binarywang.wxpay.constant;
+import com.google.common.collect.Lists;
+
import java.text.SimpleDateFormat;
+import java.util.List;
/**
*
@@ -96,9 +99,9 @@ public static class TradeType {
public static class SignType {
public static final String HMAC_SHA256 = "HMAC-SHA256";
public static final String MD5 = "MD5";
+ public static final List ALL_SIGN_TYPES = Lists.newArrayList(HMAC_SHA256, MD5);
}
-
/**
* 限定支付方式
*/
@@ -108,4 +111,170 @@ public static class LimitPay {
*/
public static final String NO_CREDIT = "no_credit";
}
+
+ /**
+ * 业务结果代码
+ */
+ public static class ResultCode {
+ /**
+ * 成功
+ */
+ public static final String SUCCESS = "SUCCESS";
+
+ /**
+ * 失败
+ */
+ public static final String FAIL = "FAIL";
+ }
+
+ /**
+ * 退款资金来源
+ */
+ public static class RefundAccountSource {
+ /**
+ * 可用余额退款/基本账户
+ */
+ public static final String RECHARGE_FUNDS = "REFUND_SOURCE_RECHARGE_FUNDS";
+
+ /**
+ * 未结算资金退款
+ */
+ public static final String UNSETTLED_FUNDS = "REFUND_SOURCE_UNSETTLED_FUNDS";
+
+ }
+
+ /**
+ * 退款渠道
+ */
+ public static class RefundChannel {
+ /**
+ * 原路退款
+ */
+ public static final String ORIGINAL = "ORIGINAL";
+
+ /**
+ * 退回到余额
+ */
+ public static final String BALANCE = "BALANCE";
+
+ /**
+ * 原账户异常退到其他余额账户
+ */
+ public static final String OTHER_BALANCE = "OTHER_BALANCE";
+
+ /**
+ * 原银行卡异常退到其他银行卡
+ */
+ public static final String OTHER_BANKCARD = "OTHER_BANKCARD";
+ }
+
+ /**
+ * 交易状态
+ */
+ public static class WxpayTradeStatus {
+ /**
+ * 支付成功
+ */
+ public static final String SUCCESS = "SUCCESS";
+
+ /**
+ * 支付失败(其他原因,如银行返回失败)
+ */
+ public static final String PAY_ERROR = "PAYERROR";
+
+ /**
+ * 用户支付中
+ */
+ public static final String USER_PAYING = "USERPAYING";
+
+ /**
+ * 已关闭
+ */
+ public static final String CLOSED = "CLOSED";
+
+ /**
+ * 未支付
+ */
+ public static final String NOTPAY = "NOTPAY";
+
+ /**
+ * 转入退款
+ */
+ public static final String REFUND = "REFUND";
+
+ /**
+ * 已撤销(刷卡支付)
+ */
+ public static final String REVOKED = "REVOKED";
+ }
+
+ /**
+ * 退款状态
+ */
+ public static class RefundStatus {
+ /**
+ * 退款成功
+ */
+ public static final String SUCCESS = "SUCCESS";
+
+ /**
+ * 退款关闭
+ */
+ public static final String REFUND_CLOSE = "REFUNDCLOSE";
+
+ /**
+ * 退款处理中
+ */
+ public static final String PROCESSING = "PROCESSING";
+
+ /**
+ * 退款异常,退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往商户平台(pay.weixin.qq.com)-交易中心,手动处理此笔退款。
+ */
+ public static final String CHANGE = "CHANGE";
+ }
+
+ /**
+ * 关闭订单结果错误代码
+ */
+ public static class OrderCloseResultErrorCode {
+ /**
+ * 订单已支付
+ */
+ public static final String ORDER_PAID = "ORDERPAID";
+
+ /**
+ * 系统错误
+ */
+ public static final String SYSTEM_ERROR = "SYSTEMERROR";
+
+ /**
+ * 订单不存在
+ */
+ public static final String ORDER_NOT_EXIST = "ORDERNOTEXIST";
+
+ /**
+ * 订单已关闭
+ */
+ public static final String ORDER_CLOSED = "ORDERCLOSED";
+
+ /**
+ * 签名错误
+ */
+ public static final String SIGN_ERROR = "SIGNERROR";
+
+ /**
+ * 未使用POST传递参数
+ */
+ public static final String REQUIRE_POST_METHOD = "REQUIRE_POST_METHOD";
+
+ /**
+ * XML格式错误
+ */
+ public static final String XML_FORMAT_ERROR = "XML_FORMAT_ERROR";
+
+ /**
+ * 订单状态错误
+ */
+ public static final String TRADE_STATE_ERROR = "TRADE_STATE_ERROR";
+ }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java
index ae058e1478..33cd56c6c9 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java
@@ -19,7 +19,7 @@
* Created by Binary Wang on 2016/7/28.
*
*
- * @author binarywang (https://github.com/binarywang)
+ * @author Binary Wang
*/
public interface WxPayService {
@@ -56,6 +56,15 @@ public interface WxPayService {
*/
WxPayOrderCloseResult closeOrder(String outTradeNo) throws WxPayException;
+ /**
+ * 调用统一下单接口,并组装生成支付所需参数对象
+ *
+ * @param request 统一下单请求参数
+ * @param 请使用{@link com.github.binarywang.wxpay.bean.order}包下的类
+ * @return 返回 {@link com.github.binarywang.wxpay.bean.order}包下的类对象
+ */
+ T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException;
+
/**
* 统一下单(详见https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_1)
* 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"
@@ -70,7 +79,9 @@ public interface WxPayService {
* 详见https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_5
*
* @param request 请求对象,注意一些参数如appid、mchid等不用设置,方法内会自动从配置对象中获取到(前提是对应配置中已经设置)
+ * @deprecated 建议使用 {@link com.github.binarywang.wxpay.service.WxPayService#createOrder(WxPayUnifiedOrderRequest)}
*/
+ @Deprecated
Map getPayInfo(WxPayUnifiedOrderRequest request) throws WxPayException;
/**
@@ -117,7 +128,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri
/**
* @see WxPayService#parseOrderNotifyResult(String)
- * @deprecated use WxPayService#parseOrderNotifyResult(String) instead
+ * @deprecated use {@link WxPayService#parseOrderNotifyResult(String)} instead
*/
@Deprecated
WxPayOrderNotifyResult getOrderNotifyResult(String xmlData) throws WxPayException;
@@ -403,6 +414,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri
* 是否需要证书:需要
* 文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_17&index=10
*
+ *
* @param beginDate 开始时间
* @param endDate 结束时间
* @param offset 位移
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java
index e77d3e1fc8..0eccb7272a 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java
@@ -72,12 +72,12 @@ private String getPayBaseUrl() {
@Override
public WxPayRefundResult refund(WxPayRefundRequest request) throws WxPayException {
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/secapi/pay/refund";
String responseContent = this.post(url, request.toXML(), true);
WxPayRefundResult result = WxPayBaseResult.fromXML(responseContent, WxPayRefundResult.class);
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
return result;
}
@@ -90,13 +90,13 @@ public WxPayRefundQueryResult refundQuery(String transactionId, String outTradeN
request.setOutRefundNo(StringUtils.trimToNull(outRefundNo));
request.setRefundId(StringUtils.trimToNull(refundId));
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/pay/refundquery";
String responseContent = this.post(url, request.toXML(), false);
WxPayRefundQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayRefundQueryResult.class);
result.composeRefundRecords();
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
return result;
}
@@ -112,7 +112,7 @@ public WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData) throws WxPa
log.debug("微信支付异步通知请求参数:{}", xmlData);
WxPayOrderNotifyResult result = WxPayOrderNotifyResult.fromXML(xmlData);
log.debug("微信支付异步通知请求解析后的对象:{}", result);
- result.checkResult(this);
+ result.checkResult(this, null, false);
return result;
} catch (WxPayException e) {
log.error(e.getMessage(), e);
@@ -138,7 +138,7 @@ public WxPayRefundNotifyResult parseRefundNotifyResult(String xmlData) throws Wx
@Override
public WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request) throws WxPayException {
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/mmpaymkttransfers/sendredpack";
if (request.getAmtType() != null) {
@@ -147,10 +147,8 @@ public WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request) throw
}
String responseContent = this.post(url, request.toXML(), true);
- WxPaySendRedpackResult result = WxPayBaseResult.fromXML(responseContent, WxPaySendRedpackResult.class);
- //毋须校验,因为没有返回签名信息
- // this.checkResult(result);
- return result;
+ //无需校验,因为没有返回签名信息
+ return WxPayBaseResult.fromXML(responseContent, WxPaySendRedpackResult.class);
}
@Override
@@ -158,12 +156,12 @@ public WxPayRedpackQueryResult queryRedpack(String mchBillNo) throws WxPayExcept
WxPayRedpackQueryRequest request = new WxPayRedpackQueryRequest();
request.setMchBillNo(mchBillNo);
request.setBillType(BillType.MCHT);
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gethbinfo";
String responseContent = this.post(url, request.toXML(), true);
WxPayRedpackQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayRedpackQueryResult.class);
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
return result;
}
@@ -172,7 +170,7 @@ public WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo)
WxPayOrderQueryRequest request = new WxPayOrderQueryRequest();
request.setOutTradeNo(StringUtils.trimToNull(outTradeNo));
request.setTransactionId(StringUtils.trimToNull(transactionId));
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/pay/orderquery";
String responseContent = this.post(url, request.toXML(), false);
@@ -182,7 +180,7 @@ public WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo)
WxPayOrderQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderQueryResult.class);
result.composeCoupons();
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
return result;
}
@@ -194,16 +192,17 @@ public WxPayOrderCloseResult closeOrder(String outTradeNo) throws WxPayException
WxPayOrderCloseRequest request = new WxPayOrderCloseRequest();
request.setOutTradeNo(StringUtils.trimToNull(outTradeNo));
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/pay/closeorder";
String responseContent = this.post(url, request.toXML(), false);
WxPayOrderCloseResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderCloseResult.class);
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
return result;
}
+ @Override
public T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException {
WxPayUnifiedOrderResult unifiedOrderResult = this.unifiedOrder(request);
String prepayId = unifiedOrderResult.getPrepayId();
@@ -214,13 +213,13 @@ public T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
String nonceStr = String.valueOf(System.currentTimeMillis());
- Object payResult = null;
switch (request.getTradeType()) {
case TradeType.NATIVE: {
- payResult = WxPayNativeOrderResult.newBuilder().codeUrl(unifiedOrderResult.getCodeURL())
+ return (T) WxPayNativeOrderResult.builder()
+ .codeUrl(unifiedOrderResult.getCodeURL())
.build();
- break;
}
+
case TradeType.APP: {
// APP支付绑定的是微信开放平台上的账号,APPID为开放平台上绑定APP后发放的参数
String appId = this.getConfig().getAppId();
@@ -235,8 +234,8 @@ public T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException
configMap.put("noncestr", nonceStr);
configMap.put("appid", appId);
- payResult = WxPayAppOrderResult.newBuilder()
- .sign(SignUtils.createSign(configMap, this.getConfig().getMchKey(), null))
+ return (T) WxPayAppOrderResult.builder()
+ .sign(SignUtils.createSign(configMap, null, this.getConfig().getMchKey(), false))
.prepayId(prepayId)
.partnerId(partnerId)
.appId(appId)
@@ -244,37 +243,48 @@ public T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException
.timeStamp(timestamp)
.nonceStr(nonceStr)
.build();
- break;
}
+
case TradeType.JSAPI: {
- payResult = WxPayMpOrderResult.newBuilder()
+ String signType = SignType.MD5;
+ WxPayMpOrderResult payResult = WxPayMpOrderResult.builder()
.appId(unifiedOrderResult.getAppid())
.timeStamp(timestamp)
.nonceStr(nonceStr)
.packageValue("prepay_id=" + prepayId)
- .signType(SignType.MD5)
+ .signType(signType)
.build();
- ((WxPayMpOrderResult) payResult)
- .setPaySign(SignUtils.createSign(payResult, this.getConfig().getMchKey(), null));
- break;
+
+ payResult.setPaySign(
+ SignUtils.createSign(
+ payResult,
+ signType,
+ this.getConfig().getMchKey(),
+ false)
+ );
+ return (T) payResult;
+ }
+
+ default: {
+ throw new WxPayException("该交易类型暂不支持");
}
}
- return (T) payResult;
}
@Override
public WxPayUnifiedOrderResult unifiedOrder(WxPayUnifiedOrderRequest request) throws WxPayException {
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/pay/unifiedorder";
String responseContent = this.post(url, request.toXML(), false);
WxPayUnifiedOrderResult result = WxPayBaseResult.fromXML(responseContent, WxPayUnifiedOrderResult.class);
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
return result;
}
@Override
+ @Deprecated
public Map getPayInfo(WxPayUnifiedOrderRequest request) throws WxPayException {
WxPayUnifiedOrderResult unifiedOrderResult = this.unifiedOrder(request);
String prepayId = unifiedOrderResult.getPrepayId();
@@ -302,7 +312,7 @@ public Map getPayInfo(WxPayUnifiedOrderRequest request) throws W
configMap.put("noncestr", nonceStr);
configMap.put("appid", appId);
// 此map用于客户端与微信服务器交互
- payInfo.put("sign", SignUtils.createSign(configMap, this.getConfig().getMchKey(), null));
+ payInfo.put("sign", SignUtils.createSign(configMap, null, this.getConfig().getMchKey(), false));
payInfo.put("prepayId", prepayId);
payInfo.put("partnerId", partnerId);
payInfo.put("appId", appId);
@@ -316,7 +326,7 @@ public Map getPayInfo(WxPayUnifiedOrderRequest request) throws W
payInfo.put("nonceStr", nonceStr);
payInfo.put("package", "prepay_id=" + prepayId);
payInfo.put("signType", SignType.MD5);
- payInfo.put("paySign", SignUtils.createSign(payInfo, this.getConfig().getMchKey(), null));
+ payInfo.put("paySign", SignUtils.createSign(payInfo, null, this.getConfig().getMchKey(), false));
}
return payInfo;
@@ -324,12 +334,12 @@ public Map getPayInfo(WxPayUnifiedOrderRequest request) throws W
@Override
public WxEntPayResult entPay(WxEntPayRequest request) throws WxPayException {
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/mmpaymkttransfers/promotion/transfers";
String responseContent = this.post(url, request.toXML(), true);
WxEntPayResult result = WxPayBaseResult.fromXML(responseContent, WxEntPayResult.class);
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
return result;
}
@@ -337,12 +347,12 @@ public WxEntPayResult entPay(WxEntPayRequest request) throws WxPayException {
public WxEntPayQueryResult queryEntPay(String partnerTradeNo) throws WxPayException {
WxEntPayQueryRequest request = new WxEntPayQueryRequest();
request.setPartnerTradeNo(partnerTradeNo);
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gettransferinfo";
String responseContent = this.post(url, request.toXML(), true);
WxEntPayQueryResult result = WxPayBaseResult.fromXML(responseContent, WxEntPayQueryResult.class);
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
return result;
}
@@ -363,7 +373,7 @@ public String createScanPayQrcodeMode1(String productId) {
params.put("time_stamp", String.valueOf(System.currentTimeMillis() / 1000));//这里需要秒,10位数字
params.put("nonce_str", String.valueOf(System.currentTimeMillis()));
- String sign = SignUtils.createSign(params, this.getConfig().getMchKey(), null);
+ String sign = SignUtils.createSign(params, null, this.getConfig().getMchKey(), false);
params.put("sign", sign);
for (String key : params.keySet()) {
@@ -388,13 +398,14 @@ private byte[] createQrcode(String content, File logoFile, Integer sideLength) {
return QrcodeUtils.createQrcode(content, sideLength, logoFile);
}
+ @Override
public void report(WxPayReportRequest request) throws WxPayException {
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/payitil/report";
String responseContent = this.post(url, request.toXML(), false);
WxPayCommonResult result = WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class);
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
}
@Override
@@ -405,15 +416,15 @@ public WxPayBillResult downloadBill(String billDate, String billType, String tar
request.setTarType(tarType);
request.setDeviceInfo(deviceInfo);
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/pay/downloadbill";
String responseContent = this.post(url, request.toXML(), false);
if (responseContent.startsWith("<")) {
throw WxPayException.from(WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class));
- } else {
- return this.handleBillInformation(responseContent);
}
+
+ return this.handleBillInformation(responseContent);
}
private WxPayBillResult handleBillInformation(String responseContent) {
@@ -446,7 +457,7 @@ private WxPayBillResult handleBillInformation(String responseContent) {
wxPayBillBaseResult.setMchId(tempStr[k + 2].trim());
wxPayBillBaseResult.setSubMchId(tempStr[k + 3].trim());
wxPayBillBaseResult.setDeviceInfo(tempStr[k + 4].trim());
- wxPayBillBaseResult.setTransationId(tempStr[k + 5].trim());
+ wxPayBillBaseResult.setTransactionId(tempStr[k + 5].trim());
wxPayBillBaseResult.setOutTradeNo(tempStr[k + 6].trim());
wxPayBillBaseResult.setOpenId(tempStr[k + 7].trim());
wxPayBillBaseResult.setTradeType(tempStr[k + 8].trim());
@@ -487,34 +498,34 @@ private WxPayBillResult handleBillInformation(String responseContent) {
@Override
public WxPayMicropayResult micropay(WxPayMicropayRequest request) throws WxPayException {
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/pay/micropay";
String responseContent = this.post(url, request.toXML(), false);
WxPayMicropayResult result = WxPayBaseResult.fromXML(responseContent, WxPayMicropayResult.class);
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
return result;
}
@Override
public WxPayOrderReverseResult reverseOrder(WxPayOrderReverseRequest request) throws WxPayException {
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/secapi/pay/reverse";
String responseContent = this.post(url, request.toXML(), true);
WxPayOrderReverseResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderReverseResult.class);
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
return result;
}
@Override
public String shorturl(WxPayShorturlRequest request) throws WxPayException {
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/tools/shorturl";
String responseContent = this.post(url, request.toXML(), false);
WxPayShorturlResult result = WxPayBaseResult.fromXML(responseContent, WxPayShorturlResult.class);
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
return result.getShortUrl();
}
@@ -525,12 +536,12 @@ public String shorturl(String longUrl) throws WxPayException {
@Override
public String authcode2Openid(WxPayAuthcode2OpenidRequest request) throws WxPayException {
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/tools/authcodetoopenid";
String responseContent = this.post(url, request.toXML(), false);
WxPayAuthcode2OpenidResult result = WxPayBaseResult.fromXML(responseContent, WxPayAuthcode2OpenidResult.class);
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
return result.getOpenid();
}
@@ -542,45 +553,45 @@ public String authcode2Openid(String authCode) throws WxPayException {
@Override
public String getSandboxSignKey() throws WxPayException {
WxPayDefaultRequest request = new WxPayDefaultRequest();
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = "https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey";
String responseContent = this.post(url, request.toXML(), false);
WxPaySandboxSignKeyResult result = WxPayBaseResult.fromXML(responseContent, WxPaySandboxSignKeyResult.class);
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
return result.getSandboxSignKey();
}
@Override
public WxPayCouponSendResult sendCoupon(WxPayCouponSendRequest request) throws WxPayException {
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/mmpaymkttransfers/send_coupon";
String responseContent = this.post(url, request.toXML(), true);
WxPayCouponSendResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponSendResult.class);
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
return result;
}
@Override
public WxPayCouponStockQueryResult queryCouponStock(WxPayCouponStockQueryRequest request) throws WxPayException {
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/mmpaymkttransfers/query_coupon_stock";
String responseContent = this.post(url, request.toXML(), false);
WxPayCouponStockQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponStockQueryResult.class);
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
return result;
}
@Override
public WxPayCouponInfoQueryResult queryCouponInfo(WxPayCouponInfoQueryRequest request) throws WxPayException {
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), false);
String url = this.getPayBaseUrl() + "/mmpaymkttransfers/querycouponsinfo";
String responseContent = this.post(url, request.toXML(), false);
WxPayCouponInfoQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponInfoQueryResult.class);
- result.checkResult(this);
+ result.checkResult(this, request.getSignType(), true);
return result;
}
@@ -604,7 +615,7 @@ public String queryComment(Date beginDate, Date endDate, Integer offset, Integer
request.setLimit(limit);
request.setSignType(SignType.HMAC_SHA256);
- request.checkAndSign(this.getConfig());
+ request.checkAndSign(this.getConfig(), true);
String url = this.getPayBaseUrl() + "/billcommentsp/batchquerycomment";
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java
index 1b3284f95f..653c1a8d6e 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java
@@ -27,7 +27,7 @@
* Created by Binary Wang on 2016/7/28.
*
*
- * @author binarywang (https://github.com/binarywang)
+ * @author Binary Wang
*/
public class WxPayServiceApacheHttpImpl extends WxPayServiceAbstractImpl {
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java
index bbe024a309..b342c5cda8 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java
@@ -18,7 +18,7 @@
* 微信支付请求实现类,jodd-http实现
* Created by Binary Wang on 2016/7/28.
*
- * @author binarywang (https://github.com/binarywang)
+ * @author Binary Wang
*/
public class WxPayServiceJoddHttpImpl extends WxPayServiceAbstractImpl {
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java
index b13175a724..efb9d85604 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java
@@ -1,10 +1,13 @@
package com.github.binarywang.wxpay.util;
import com.github.binarywang.wxpay.constant.WxPayConstants.SignType;
+import com.google.common.collect.Lists;
import me.chanjar.weixin.common.util.BeanUtils;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
@@ -16,96 +19,116 @@
/**
*
- * 签名相关工具类
+ * 签名相关工具类.
* Created by Binary Wang on 2017-3-23.
- * @author binarywang(Binary Wang)
*
+ *
+ * @author binarywang(Binary Wang)
*/
public class SignUtils {
+ private static final Logger log = LoggerFactory.getLogger(SignUtils.class);
+
+ /**
+ * 请参考并使用 {@link #createSign(Object, String, String, boolean)}.
+ */
+ @Deprecated
+ public static String createSign(Object xmlBean, String signKey) {
+ return createSign(BeanUtils.xmlBean2Map(xmlBean), signKey);
+ }
+
+ /**
+ * 请参考并使用 {@link #createSign(Map, String, String, boolean)}.
+ */
+ @Deprecated
+ public static String createSign(Map params, String signKey) {
+ return createSign(params, null, signKey, false);
+ }
/**
- * 微信公众号支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3)
+ * 微信支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3).
*
- * @param xmlBean Bean需要标记有XML注解
- * @param signKey 签名Key
- * @param signType 签名类型,如果为空,则默认为MD5
+ * @param xmlBean Bean里的属性如果存在XML注解,则使用其作为key,否则使用变量名
+ * @param signType 签名类型,如果为空,则默认为MD5
+ * @param signKey 签名Key
+ * @param isIgnoreSignType 签名时,是否忽略signType
* @return 签名字符串
*/
- public static String createSign(Object xmlBean, String signKey, String signType) {
- return createSign(BeanUtils.xmlBean2Map(xmlBean), signKey, signType);
+ public static String createSign(Object xmlBean, String signType, String signKey, boolean isIgnoreSignType) {
+ return createSign(BeanUtils.xmlBean2Map(xmlBean), signType, signKey, isIgnoreSignType);
}
/**
- * 微信公众号支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3)
+ * 微信支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3).
*
- * @param params 参数信息
- * @param signKey 签名Key
- * @param signType 签名类型,如果为空,则默认为md5
+ * @param params 参数信息
+ * @param signType 签名类型,如果为空,则默认为MD5
+ * @param signKey 签名Key
+ * @param ignoreSignType 签名时,是否忽略signType
* @return 签名字符串
*/
- public static String createSign(Map params, String signKey, String signType) {
-// if (this.getConfig().useSandbox()) {
-// //使用仿真测试环境
-// //TODO 目前测试发现,以下两行代码都会出问题,所以暂不建议使用仿真测试环境
-// signKey = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456";
-// //return "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456";
-// }
-
+ public static String createSign(Map params, String signType, String signKey, boolean ignoreSignType) {
SortedMap sortedMap = new TreeMap<>(params);
StringBuilder toSign = new StringBuilder();
for (String key : sortedMap.keySet()) {
String value = params.get(key);
- if (StringUtils.isNotEmpty(value)
- && !StringUtils.equalsAny(key, "sign", "key", "sign_type")) {
+ boolean shouldSign = false;
+ if (ignoreSignType && "sign_type".equals(key)) {
+ shouldSign = false;
+ } else if (StringUtils.isNotEmpty(value)
+ && !Lists.newArrayList("sign", "key", "xmlString", "xmlDoc", "couponList").contains(key)) {
+ shouldSign = true;
+ }
+
+ if (shouldSign) {
toSign.append(key).append("=").append(value).append("&");
}
}
toSign.append("key=").append(signKey);
if (SignType.HMAC_SHA256.equals(signType)) {
- return createHMACSha256Sign(toSign.toString(), signKey);
+ return createHmacSha256Sign(toSign.toString(), signKey);
} else {
return DigestUtils.md5Hex(toSign.toString()).toUpperCase();
}
}
- private static String createHMACSha256Sign(String message, String key) {
+ private static String createHmacSha256Sign(String message, String key) {
try {
- Mac hmacSHA256 = Mac.getInstance("HmacSHA256");
+ Mac sha256 = Mac.getInstance("HmacSHA256");
SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), "HmacSHA256");
- hmacSHA256.init(secretKeySpec);
- byte[] bytes = hmacSHA256.doFinal(message.getBytes());
+ sha256.init(secretKeySpec);
+ byte[] bytes = sha256.doFinal(message.getBytes());
return Hex.encodeHexString(bytes).toUpperCase();
} catch (NoSuchAlgorithmException | InvalidKeyException e) {
- e.printStackTrace();
+ log.error(e.getMessage(), e);
}
return null;
}
/**
- * 校验签名是否正确
+ * 校验签名是否正确.
*
- * @param xmlBean Bean需要标记有XML注解
- * @param signKey 校验的签名Key
+ * @param xmlBean Bean需要标记有XML注解
+ * @param signType 签名类型,如果为空,则默认为MD5
+ * @param signKey 校验的签名Key
* @return true - 签名校验成功,false - 签名校验失败
- * @see #checkSign(Map, String)
*/
- public static boolean checkSign(Object xmlBean, String signKey) {
- return checkSign(BeanUtils.xmlBean2Map(xmlBean), signKey);
+ public static boolean checkSign(Object xmlBean, String signType, String signKey) {
+ return checkSign(BeanUtils.xmlBean2Map(xmlBean), signType, signKey);
}
/**
- * 校验签名是否正确
+ * 校验签名是否正确.
*
- * @param params 需要校验的参数Map
- * @param signKey 校验的签名Key
+ * @param params 需要校验的参数Map
+ * @param signType 签名类型,如果为空,则默认为MD5
+ * @param signKey 校验的签名Key
* @return true - 签名校验成功,false - 签名校验失败
- * @see #checkSign(Map, String)
*/
- public static boolean checkSign(Map params, String signKey) {
- String sign = createSign(params, signKey, null);
+ public static boolean checkSign(Map params, String signType, String signKey) {
+ String sign = createSign(params, signType, signKey, false);
return sign.equals(params.get("sign"));
}
}
diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java
index 2fc5354424..9c293103b6 100644
--- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java
+++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java
@@ -2,6 +2,10 @@
import com.github.binarywang.utils.qrcode.QrcodeUtils;
import com.github.binarywang.wxpay.bean.coupon.*;
+import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
+import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult;
+import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
+import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult;
import com.github.binarywang.wxpay.bean.request.*;
import com.github.binarywang.wxpay.bean.result.*;
import com.github.binarywang.wxpay.constant.WxPayConstants;
@@ -15,14 +19,12 @@
import com.google.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testng.annotations.Guice;
-import org.testng.annotations.Test;
+import org.testng.annotations.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Calendar;
import java.util.Date;
-import java.util.Map;
import static org.testng.Assert.*;
@@ -30,7 +32,7 @@
* 测试支付相关接口
* Created by Binary Wang on 2016/7/28.
*
- * @author binarywang (https://github.com/binarywang)
+ * @author Binary Wang
*/
@Test
@Guice(modules = ApiTestModule.class)
@@ -45,8 +47,30 @@ public class WxPayServiceAbstractImplTest {
*/
@Test
public void testUnifiedOrder() throws WxPayException {
- WxPayUnifiedOrderResult result = this.payService
- .unifiedOrder(WxPayUnifiedOrderRequest.newBuilder()
+ WxPayUnifiedOrderRequest request = WxPayUnifiedOrderRequest.newBuilder()
+ .body("我去")
+ .totalFee(1)
+ .spbillCreateIp("11.1.11.1")
+ .notifyURL("111111")
+ .tradeType(TradeType.JSAPI)
+ .openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid())
+ .outTradeNo("1111112")
+ .build();
+ request.setSignType(SignType.HMAC_SHA256);
+ WxPayUnifiedOrderResult result = this.payService.unifiedOrder(request);
+ this.logger.info(result.toString());
+ this.logger.warn(this.payService.getWxApiData().toString());
+ }
+
+ @Test
+ public void testCreateOrder() throws Exception {
+ //see other tests with method name starting with 'testCreateOrder_'
+ }
+
+ @Test
+ public void testCreateOrder_jsapi() throws Exception {
+ WxPayMpOrderResult result = this.payService
+ .createOrder(WxPayUnifiedOrderRequest.newBuilder()
.body("我去")
.totalFee(1)
.spbillCreateIp("11.1.11.1")
@@ -59,18 +83,40 @@ public void testUnifiedOrder() throws WxPayException {
this.logger.warn(this.payService.getWxApiData().toString());
}
+ @Test
+ public void testCreateOrder_app() throws Exception {
+ WxPayAppOrderResult result = this.payService
+ .createOrder(WxPayUnifiedOrderRequest.newBuilder()
+ .body("我去")
+ .totalFee(1)
+ .spbillCreateIp("11.1.11.1")
+ .notifyURL("111111")
+ .tradeType(TradeType.APP)
+ .outTradeNo("1111112")
+ .build());
+ this.logger.info(result.toString());
+ this.logger.warn(this.payService.getWxApiData().toString());
+ }
+
+ @Test
+ public void testCreateOrder_native() throws Exception {
+ WxPayNativeOrderResult result = this.payService
+ .createOrder(WxPayUnifiedOrderRequest.newBuilder()
+ .body("我去")
+ .totalFee(1)
+ .productId("aaa")
+ .spbillCreateIp("11.1.11.1")
+ .notifyURL("111111")
+ .tradeType(TradeType.NATIVE)
+ .outTradeNo("111111290")
+ .build());
+ this.logger.info(result.toString());
+ this.logger.warn(this.payService.getWxApiData().toString());
+ }
+
@Test
public void testGetPayInfo() throws Exception {
- Map payInfo = this.payService.getPayInfo(WxPayUnifiedOrderRequest.newBuilder()
- .body("我去")
- .totalFee(1)
- .spbillCreateIp("1.11.1.11")
- .notifyURL("111111")
- .tradeType(TradeType.JSAPI)
- .outTradeNo("1111113")
- .openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid())
- .build());
- this.logger.info(payInfo.toString());
+ //please use createOrder instead
}
/**
@@ -90,11 +136,24 @@ public void testCloseOrder() throws WxPayException {
this.logger.info(this.payService.closeOrder("11212121").toString());
}
+ @DataProvider
+ public Object[][] billingData() {
+ return new Object[][]{
+// {"20170831", BillType.ALL, null, "deviceInfo"},
+ {"20170831", BillType.SUCCESS, null, "deviceInfo"}
+ };
+ }
+
+ @Test(dataProvider = "billingData")
+ public void testDownloadBill(String billDate, String billType,
+ String tarType, String deviceInfo) throws Exception {
+ WxPayBillResult billResult = this.payService.downloadBill(billDate, billType, tarType, deviceInfo);
+ assertNotNull(billResult);
+ this.logger.info(billResult.toString());
+ }
+
@Test
- public void testDownloadBill() throws Exception {
- WxPayBillResult wxPayBillResult = this.payService.downloadBill("20170831", BillType.ALL, null, "1111111");
- //前一天没有账单记录返回null
- assertNotNull(wxPayBillResult);
+ public void testDownloadBill_withNoParams() throws Exception {
//必填字段为空时,抛出异常
this.payService.downloadBill("", "", "", null);
}
@@ -225,19 +284,17 @@ public void testCreateScanPayQrcodeMode2() throws Exception {
assertEquals(QrcodeUtils.decodeQrcode(qrcodeFilePath.toFile()), qrcodeContent);
}
- @Test
- public void testGetOrderNotifyResult() throws Exception {
- }
-
@Test
public void testMicropay() throws Exception {
- WxPayMicropayResult result = this.payService.micropay(WxPayMicropayRequest.newBuilder()
- .body("body")
- .outTradeNo("aaaaa")
- .totalFee(123)
- .spbillCreateIp("127.0.0.1")
- .authCode("aaa")
- .build());
+ WxPayMicropayResult result = this.payService.micropay(
+ WxPayMicropayRequest
+ .newBuilder()
+ .body("body")
+ .outTradeNo("aaaaa")
+ .totalFee(123)
+ .spbillCreateIp("127.0.0.1")
+ .authCode("aaa")
+ .build());
this.logger.info(result.toString());
}
@@ -253,9 +310,11 @@ public void testSetConfig() throws Exception {
@Test
public void testReverseOrder() throws Exception {
- WxPayOrderReverseResult result = this.payService.reverseOrder(WxPayOrderReverseRequest.newBuilder()
- .outTradeNo("1111")
- .build());
+ WxPayOrderReverseResult result = this.payService.reverseOrder(
+ WxPayOrderReverseRequest
+ .newBuilder()
+ .outTradeNo("1111")
+ .build());
assertNotNull(result);
this.logger.info(result.toString());
}
@@ -306,33 +365,82 @@ public void testSendCoupon() throws Exception {
@Test
public void testQueryCouponStock() throws Exception {
- WxPayCouponStockQueryResult result = this.payService.queryCouponStock(WxPayCouponStockQueryRequest.newBuilder()
- .couponStockId("123")
- .build());
+ WxPayCouponStockQueryResult result = this.payService.queryCouponStock(
+ WxPayCouponStockQueryRequest
+ .newBuilder()
+ .couponStockId("123")
+ .build());
this.logger.info(result.toString());
}
@Test
public void testQueryCouponInfo() throws Exception {
- WxPayCouponInfoQueryResult result = this.payService.queryCouponInfo(WxPayCouponInfoQueryRequest.newBuilder()
- .openid("ojOQA0y9o-Eb6Aep7uVTdbkJqrP4")
- .couponId("11")
- .stockId("1121")
- .build());
+ WxPayCouponInfoQueryResult result = this.payService.queryCouponInfo(
+ WxPayCouponInfoQueryRequest
+ .newBuilder()
+ .openid("ojOQA0y9o-Eb6Aep7uVTdbkJqrP4")
+ .couponId("11")
+ .stockId("1121")
+ .build());
this.logger.info(result.toString());
}
/**
- * 目前调用接口总报“系统繁忙,清稍后再试”,怀疑根本没法使用
+ * 只支持拉取90天内的评论数据
*/
@Test
public void testQueryComment() throws Exception {
Calendar calendar = Calendar.getInstance();
- calendar.add(Calendar.DAY_OF_MONTH, -2);
- Date beginDate = calendar.getTime();
- calendar.add(Calendar.MONTH, -1);
+ calendar.add(Calendar.DAY_OF_MONTH, -1);
Date endDate = calendar.getTime();
- this.payService.queryComment(beginDate, endDate, 0, null);
+ calendar.add(Calendar.DAY_OF_MONTH, -88);
+ Date beginDate = calendar.getTime();
+ String result = this.payService.queryComment(beginDate, endDate, 0, null);
+ this.logger.info(result);
+ }
+
+ /**
+ * @see {@link com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResultTest}
+ * @throws Exception
+ */
+ @Test
+ public void testParseOrderNotifyResult() throws Exception {
+ // 请参考com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResultTest 里的单元测试
+
+ String xmlString = "\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " 1 \n" +
+ " \n" +
+ " \n" +
+ " 2 \n" +
+ " \n" +
+ " 10000 \n" +
+ " 100 \n" +
+ " \n" +
+ " 10001 \n" +
+ " 200 \n" +
+ " ";
+
+ WxPayOrderNotifyResult result = this.payService.parseOrderNotifyResult(xmlString);
+ System.out.println(result);
+ }
+
+ @Test
+ public void testGetWxApiData() throws Exception {
+ //see test in testUnifiedOrder()
}
}
diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/util/SignUtilsTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/util/SignUtilsTest.java
index 23d7088b7b..57c185b544 100644
--- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/util/SignUtilsTest.java
+++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/util/SignUtilsTest.java
@@ -20,7 +20,7 @@ public class SignUtilsTest {
public void testCreateSign() throws Exception {
String signKey = "192006250b4c09247ec02edce69f6a2d";
String message = "appid=wxd930ea5d5a258f4f&body=test&device_info=1000&mch_id=10000100&nonce_str=ibuaiVcKdpRxkhJA";
- assertEquals(SignUtils.createSign((Splitter.on("&").withKeyValueSeparator("=").split(message)), signKey, null),
+ assertEquals(SignUtils.createSign((Splitter.on("&").withKeyValueSeparator("=").split(message)), null, signKey, false),
"9A0A8659F005D6984697E2CA0A9CF3B7");
}
@@ -29,7 +29,7 @@ public void testCreateSign_HMACSHA256() throws Exception {
String signKey = "192006250b4c09247ec02edce69f6a2d";
final String message = "appid=wxd930ea5d5a258f4f&body=test&device_info=1000&mch_id=10000100&nonce_str=ibuaiVcKdpRxkhJA";
String sign = SignUtils.createSign(Splitter.on("&").withKeyValueSeparator("=").split(message),
- signKey, HMAC_SHA256);
+ HMAC_SHA256, signKey, false);
assertEquals(sign, "6A9AE1657590FD6257D693A078E1C3E4BB6BA4DC30B23E0EE2496E54170DACD6");
}