diff --git a/.github/agents/my-agent.agent.md b/.github/agents/my-agent.agent.md
index dcce85fd88..0c8481288a 100644
--- a/.github/agents/my-agent.agent.md
+++ b/.github/agents/my-agent.agent.md
@@ -10,4 +10,5 @@ description: 需要用中文,包括PR标题和分析总结过程
# My Agent
-请使用中文输出思考过程和总结,包括PR标题,提交commit信息也要使用中文
+1、请使用中文输出思考过程和总结,包括PR标题,提交commit信息也要使用中文;
+2、生成代码时需要提供必要的单元测试代码。
diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml
index de68370ae1..a12c20b112 100644
--- a/.github/workflows/maven-publish.yml
+++ b/.github/workflows/maven-publish.yml
@@ -33,7 +33,22 @@ jobs:
VERSION="${BASE_VER}.B"
TAG="v${BASE_VER}"
IS_RELEASE="true"
- echo "Matched release commit: VERSION=$VERSION, TAG=$TAG"
+ echo "Matched test release commit: VERSION=$VERSION, TAG=$TAG"
+ # 检查并打tag
+ if git tag | grep -q "^$TAG$"; then
+ echo "Tag $TAG already exists."
+ else
+ git config user.name "Binary Wang"
+ git config user.email "a@binarywang.com"
+ git tag -a "$TAG" -m "Release $TAG"
+ git push origin "$TAG"
+ echo "Tag $TAG created and pushed."
+ fi
+ elif [[ "$COMMIT_MSG" =~ ^:bookmark:\ 发布\ ([0-9]+\.[0-9]+\.[0-9]+)\ 正式版本 ]]; then
+ VERSION="${BASH_REMATCH[1]}"
+ TAG="v${VERSION}"
+ IS_RELEASE="true"
+ echo "Matched formal release commit: VERSION=$VERSION, TAG=$TAG"
# 检查并打tag
if git tag | grep -q "^$TAG$"; then
echo "Tag $TAG already exists."
diff --git a/README.md b/README.md
index f1cccac4b3..080b831d1e 100644
--- a/README.md
+++ b/README.md
@@ -64,7 +64,7 @@
### 重要信息
1. [`WxJava` 荣获 `GitCode` 2024年度十大开源社区奖项](https://mp.weixin.qq.com/s/wM_UlMsDm3IZ1CPPDvcvQw)。
2. 项目合作洽谈请联系微信`binary0000`(在微信里自行搜索并添加好友,请注明来意,如有关于SDK问题需讨论请参考下文入群讨论,不要加此微信)。
-3. **2024-12-30 发布 [【4.7.0正式版】](https://mp.weixin.qq.com/s/_7k-XLYBqeJJhvHWCsdT0A)**!
+3. **2026-01-03 发布 [【4.8.0正式版】](https://mp.weixin.qq.com/s/mJoFtGc25pXCn3uZRh6Q-w)**!
5. 贡献源码可以参考视频:[【贡献源码全过程(上集)】](https://mp.weixin.qq.com/s/3xUZSATWwHR_gZZm207h7Q)、[【贡献源码全过程(下集)】](https://mp.weixin.qq.com/s/nyzJwVVoYSJ4hSbwyvTx9A) ,友情提供:[程序员小山与Bug](https://space.bilibili.com/473631007)
6. 新手重要提示:本项目仅是一个SDK开发工具包,未提供Web实现,建议使用 `maven` 或 `gradle` 引用本项目即可使用本SDK提供的各种功能,详情可参考 **[【Demo项目】](demo.md)** 或本项目中的部分单元测试代码;
7. 微信开发新手请务必阅读【开发文档】([Gitee Wiki](https://gitee.com/binary/weixin-java-tools/wikis/Home) 或者 [Github Wiki](https://github.com/binarywang/WxJava/wiki))的常见问题部分,可以少走很多弯路,节省不少时间。
@@ -95,7 +95,7 @@
+ * 参考:{@code https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140842}
+ *
+ * 参考:{@code https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncement&announce_id=11513156443eZYea&version=&lang=zh_CN}
+ *
* 请阅读:
* 公众平台:全局返回码说明
* 企业微信:全局错误码
+ *
+ * 对应操作:{@code uploadTempMedia}
* 对应地址:
- * POST https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE
+ * {@code POST https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE}
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/uploadTempMedia.html
- *
* 无效媒体文件类型
- * 对应操作:
+ * uploadTempMedia
+ *
* 无效媒体文件 ID.
- * 对应操作:getTempMedia
+ *
+ * 对应操作:{@code getTempMedia}
* 对应地址:
- * GET https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID
+ * {@code GET https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID}
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/getTempMedia.html
- *
+ *
*/
CODE_40007(40007, "无效媒体文件 ID"),
/**
@@ -99,29 +99,29 @@ public enum WxMaErrorMsgEnum {
*/
CODE_41028(41028, "form_id 不正确,或者过期"),
/**
- *
* code 或 template_id 不正确.
- * 对应操作:code2Session, sendUniformMessage, sendTemplateMessage
+ *
+ * 对应操作:{@code code2Session}, {@code sendUniformMessage}, {@code sendTemplateMessage}
* 对应地址:
- * GET https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code
+ * {@code GET https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code}
* POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN
* POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/code2Session.html
* https://developers.weixin.qq.com/miniprogram/dev/api/open-api/uniform-message/sendUniformMessage.html
* https://developers.weixin.qq.com/miniprogram/dev/api/open-api/template-message/sendTemplateMessage.html
- *
+ *
*/
CODE_41029(41029, "请求的参数不正确"),
/**
- *
* form_id 已被使用,或者所传page页面不存在,或者小程序没有发布
- * 对应操作:sendUniformMessage, getWXACodeUnlimit
+ *
+ * 对应操作:{@code sendUniformMessage}, {@code getWXACodeUnlimit}
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN
* POST https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/uniform-message/sendUniformMessage.html
- * https://developers.weixin.qq.com/miniprogram/dev/api/open-api/qr-code/getWXACodeUnlimit.html
- *
+ * https://developers.weixin.qq.com/miniprogram/dev/api/open-api/qr-code/getWXACodeUnlimit.html
+ *
*/
CODE_41030(41030, "请求的参数不正确"),
/**
@@ -138,13 +138,13 @@ public enum WxMaErrorMsgEnum {
*/
CODE_45009(45009, "调用分钟频率受限"),
/**
- *
* 频率限制,每个用户每分钟100次.
- * 对应操作:code2Session
+ *
+ * 对应操作:{@code code2Session}
* 对应地址:
- * GET https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code
+ * {@code GET https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code}
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/code2Session.html
- *
+ *
*/
CODE_45011(45011, "频率限制,每个用户每分钟100次"),
/**
@@ -190,12 +190,13 @@ public enum WxMaErrorMsgEnum {
*/
CODE_45072(45072, "command字段取值不对"),
/**
- *
* 下发输入状态,需要之前30秒内跟用户有过消息交互.
- * 对应操作:customerTyping
+ *
+ * 对应操作:{@code customerTyping}
* 对应地址:
* POST https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token=ACCESS_TOKEN
* 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/customerTyping.html
+ *
*/
CODE_45080(45080, "下发输入状态,需要之前30秒内跟用户有过消息交互"),
/**
@@ -686,7 +687,7 @@ public enum WxMaErrorMsgEnum {
/**
* 89252
- * 法人&企业信息一致性校验中 front checking
+ * {@code 法人&企业信息一致性校验中 front checking}
*/
CODE_89252(89252, "法人&企业信息一致性校验中"),
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxOpenErrorMsgEnum.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxOpenErrorMsgEnum.java
index 28fb5de8ad..ba910e988b 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxOpenErrorMsgEnum.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/error/WxOpenErrorMsgEnum.java
@@ -527,7 +527,7 @@ public enum WxOpenErrorMsgEnum {
CODE_40099(40099, "invalid code, this code has consumed."),
/**
- * invalid DateInfo, Make Sure OldDateInfoType==NewDateInfoType && NewBeginTime<=OldBeginTime && OldEndTime<= NewEndTime
+ * {@code invalid DateInfo, Make Sure OldDateInfoType==NewDateInfoType && NewBeginTime<=OldBeginTime && OldEndTime<= NewEndTime}
*/
CODE_40100(40100, "invalid DateInfo, Make Sure OldDateInfoType==NewDateInfoType && NewBeginTime<=OldBeginTime && OldEndTime<= NewEndTime"),
@@ -572,7 +572,7 @@ public enum WxOpenErrorMsgEnum {
CODE_40108(40108, "invalid client version"),
/**
- * too many code size, must <= 100
+ * {@code too many code size, must <= 100}
*/
CODE_40109(40109, "too many code size, must <= 100"),
@@ -702,7 +702,7 @@ public enum WxOpenErrorMsgEnum {
CODE_40135(40135, "invalid not supply bonus, can not change card_id which supply bonus to be not supply"),
/**
- * invalid use DepositCodeMode, make sure sku.quantity>DepositCode.quantity
+ * {@code invalid use DepositCodeMode, make sure sku.quantity>DepositCode.quantity}
*/
CODE_40136(40136, "invalid use DepositCodeMode, make sure sku.quantity>DepositCode.quantity"),
@@ -1082,7 +1082,7 @@ public enum WxOpenErrorMsgEnum {
CODE_40211(40211, "invalid scope_data"),
/**
- * paegs 当中存在不合法的query,query格式遵循URL标准,即k1=v1&k2=v2 invalid query
+ * {@code paegs 当中存在不合法的query,query格式遵循URL标准,即k1=v1&k2=v2 invalid query}
*/
CODE_40212(40212, "paegs 当中存在不合法的query,query格式遵循URL标准,即k1=v1&k2=v2"),
@@ -4242,7 +4242,7 @@ public enum WxOpenErrorMsgEnum {
CODE_71005(71005, "limit exe count"),
/**
- * limit coin count, 1 <= coin_count <= 100000
+ * {@code limit coin count, 1 <= coin_count <= 100000}
*/
CODE_71006(71006, "limit coin count, 1 <= coin_count <= 100000"),
@@ -4347,7 +4347,7 @@ public enum WxOpenErrorMsgEnum {
CODE_72018(72018, "duplicate order id, invoice had inserted to user"),
/**
- * limit msg operation card list size, must <= 5
+ * {@code limit msg operation card list size, must <= 5}
*/
CODE_72019(72019, "limit msg operation card list size, must <= 5"),
@@ -6432,7 +6432,7 @@ public enum WxOpenErrorMsgEnum {
CODE_88009(88009, "reply is not exists"),
/**
- * count range error. cout <= 0 or count > 50
+ * {@code count range error. cout <= 0 or count > 50}
*/
CODE_88010(88010, "count range error. cout <= 0 or count > 50"),
@@ -6682,7 +6682,7 @@ public enum WxOpenErrorMsgEnum {
CODE_89251(89251, "模板消息已下发,待法人人脸核身校验"),
/**
- * 法人&企业信息一致性校验中 front checking
+ * {@code 法人&企业信息一致性校验中 front checking}
*/
CODE_89253(89253, "法人&企业信息一致性校验中"),
@@ -7257,7 +7257,7 @@ public enum WxOpenErrorMsgEnum {
CODE_200021(200021, "场景描述 sceneDesc 参数错误"),
/**
- * 禁止创建/更新商品(如商品创建功能被封禁) 或 禁止编辑&更新房间
+ * {@code 禁止创建/更新商品(如商品创建功能被封禁) 或 禁止编辑&更新房间}
*/
CODE_300001(300001, "禁止创建/更新商品(如商品创建功能被封禁) 或 禁止编辑&更新房间"),
@@ -8382,7 +8382,7 @@ public enum WxOpenErrorMsgEnum {
CODE_9300003(9300003, "begin_time must less than end_time"),
/**
- * end_time - begin_time > 1year
+ * {@code end_time - begin_time > 1year}
*/
CODE_9300004(9300004, "end_time - begin_time > 1year"),
@@ -8397,7 +8397,7 @@ public enum WxOpenErrorMsgEnum {
CODE_9300006(9300006, "invalid activity status"),
/**
- * gift_num must >0 and <=15
+ * {@code gift_num must >0 and <=15}
*/
CODE_9300007(9300007, "gift_num must >0 and <=15"),
@@ -8412,7 +8412,7 @@ public enum WxOpenErrorMsgEnum {
CODE_9300009(9300009, "activity can not finish"),
/**
- * card_info_list must >= 2
+ * {@code card_info_list must >= 2}
*/
CODE_9300010(9300010, "card_info_list must >= 2"),
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOcrService.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOcrService.java
index 39a8a93754..d0aeef8491 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOcrService.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/service/WxOcrService.java
@@ -12,7 +12,9 @@
/**
* 基于小程序或 H5 的身份证、银行卡、行驶证 OCR 识别.
- * https://mp.weixin.qq.com/wiki?t=resource/res_main&id=21516712284rHWMX
+ *
+ * 参考:{@code https://mp.weixin.qq.com/wiki?t=resource/res_main&id=21516712284rHWMX}
+ *
*
* @author Binary Wang
* created on 2019-06-22
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/InternalSessionManager.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/InternalSessionManager.java
index e3d9ab8351..24ea58ef38 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/InternalSessionManager.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/InternalSessionManager.java
@@ -7,13 +7,12 @@ public interface InternalSessionManager {
/**
* Return the active Session, associated with this Manager, with the
- * specified session id (if any); otherwise return null.
+ * specified session id (if any); otherwise return {@code null}.
*
* @param id The session id for the session to be returned
+ * @return the session or null
* @throws IllegalStateException if a new session cannot be
* instantiated for any reason
- * @throws java.io.IOException if an input/output error occurs while
- * processing this request
*/
InternalSession findSession(String id);
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/SignUtils.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/SignUtils.java
index fc3579d45c..1886209f98 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/SignUtils.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/SignUtils.java
@@ -25,6 +25,7 @@ public class SignUtils {
*
* @param message 签名数据
* @param key 签名密钥
+ * @return 签名结果
*/
public static String createHmacSha256Sign(String message, String key) {
try {
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/SHA1.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/SHA1.java
index 9b9f776768..43cc54b43d 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/SHA1.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/SHA1.java
@@ -29,7 +29,10 @@ public static String gen(String... arr) {
}
/**
- * 用&串接arr参数,生成sha1 digest.
+ * {@code 用&串接arr参数,生成sha1 digest.}
+ *
+ * @param arr 参数数组
+ * @return sha1摘要
*/
public static String genWithAmple(String... arr) {
if (StringUtils.isAnyEmpty(arr)) {
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java
index 0b0590b1e6..50362636fc 100755
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java
@@ -197,6 +197,7 @@ public EncryptContext encryptContext(String plainText) {
/**
* 对明文进行加密.
*
+ * @param randomStr 随机字符串
* @param plainText 需要加密的明文
* @return 加密后base64编码的字符串
*/
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/InputStreamData.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/InputStreamData.java
index d07873f3c4..f03932984f 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/InputStreamData.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/InputStreamData.java
@@ -10,8 +10,9 @@
/**
* 输入流数据.
- *
+ *
* InputStreamData
+ *
*
* @author zichuan.zhou91@gmail.com
* created on 2022/2/15
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 de34ca5bd1..5b13e7cc17 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
@@ -21,42 +21,66 @@ public interface ApacheHttpClientBuilder {
/**
* 代理服务器地址.
+ *
+ * @param httpProxyHost 代理服务器地址
+ * @return ApacheHttpClientBuilder
*/
ApacheHttpClientBuilder httpProxyHost(String httpProxyHost);
/**
* 代理服务器端口.
+ *
+ * @param httpProxyPort 代理服务器端口
+ * @return ApacheHttpClientBuilder
*/
ApacheHttpClientBuilder httpProxyPort(int httpProxyPort);
/**
* 代理服务器用户名.
+ *
+ * @param httpProxyUsername 代理服务器用户名
+ * @return ApacheHttpClientBuilder
*/
ApacheHttpClientBuilder httpProxyUsername(String httpProxyUsername);
/**
* 代理服务器密码.
+ *
+ * @param httpProxyPassword 代理服务器密码
+ * @return ApacheHttpClientBuilder
*/
ApacheHttpClientBuilder httpProxyPassword(String httpProxyPassword);
/**
* 重试策略.
+ *
+ * @param httpRequestRetryHandler 重试处理器
+ * @return ApacheHttpClientBuilder
*/
- ApacheHttpClientBuilder httpRequestRetryHandler(HttpRequestRetryHandler httpRequestRetryHandler );
+ ApacheHttpClientBuilder httpRequestRetryHandler(HttpRequestRetryHandler httpRequestRetryHandler);
/**
* 超时时间.
+ *
+ * @param keepAliveStrategy 保持连接策略
+ * @return ApacheHttpClientBuilder
*/
ApacheHttpClientBuilder keepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy);
/**
* ssl连接socket工厂.
+ *
+ * @param sslConnectionSocketFactory SSL连接Socket工厂
+ * @return ApacheHttpClientBuilder
*/
ApacheHttpClientBuilder sslConnectionSocketFactory(SSLConnectionSocketFactory sslConnectionSocketFactory);
/**
* 支持的TLS协议版本.
* Supported TLS protocol versions.
+ *
+ * @param supportedProtocols 支持的协议版本数组
+ * @return ApacheHttpClientBuilder
*/
ApacheHttpClientBuilder supportedProtocols(String[] supportedProtocols);
}
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxGsonBuilder.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxGsonBuilder.java
index 6ea269f7e4..8f3dafe48a 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxGsonBuilder.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxGsonBuilder.java
@@ -43,6 +43,11 @@ public boolean shouldSkipClass(Class> aClass) {
});
}
+ /**
+ * 创建Gson实例
+ *
+ * @return Gson实例
+ */
public static Gson create() {
if (Objects.isNull(GSON_INSTANCE)) {
synchronized (INSTANCE) {
diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/xml/XStreamInitializer.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/xml/XStreamInitializer.java
index 3fa91fa70e..51cd1e980c 100644
--- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/xml/XStreamInitializer.java
+++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/xml/XStreamInitializer.java
@@ -22,6 +22,11 @@ public class XStreamInitializer {
public static ClassLoader classLoader;
+ /**
+ * 设置类加载器
+ *
+ * @param classLoaderInfo 类加载器
+ */
public static void setClassLoader(ClassLoader classLoaderInfo) {
classLoader = classLoaderInfo;
}
diff --git a/weixin-java-cp/INTELLIGENT_ROBOT.md b/weixin-java-cp/INTELLIGENT_ROBOT.md
index f2641bd6b4..dcd90e1a1a 100644
--- a/weixin-java-cp/INTELLIGENT_ROBOT.md
+++ b/weixin-java-cp/INTELLIGENT_ROBOT.md
@@ -73,6 +73,42 @@ String sessionId = "session123";
robotService.resetSession(robotId, userid, sessionId);
```
+### 主动发送消息
+
+智能机器人可以主动向用户发送消息,用于推送通知或提醒。
+
+```java
+WxCpIntelligentRobotSendMessageRequest request = new WxCpIntelligentRobotSendMessageRequest();
+request.setRobotId("robot_id_here");
+request.setUserid("user123");
+request.setMessage("您好,这是来自智能机器人的主动消息");
+request.setSessionId("session123"); // 可选,用于保持会话连续性
+
+WxCpIntelligentRobotSendMessageResponse response = robotService.sendMessage(request);
+String msgId = response.getMsgId();
+String sessionId = response.getSessionId();
+```
+
+### 接收用户消息
+
+当用户向智能机器人发送消息时,企业微信会通过回调接口推送消息。可以使用 `WxCpXmlMessage` 接收和解析这些消息:
+
+```java
+// 在接收回调消息的接口中
+WxCpXmlMessage message = WxCpXmlMessage.fromEncryptedXml(
+ requestBody, wxCpConfigStorage, timestamp, nonce, msgSignature
+);
+
+// 获取智能机器人相关字段
+String robotId = message.getRobotId(); // 机器人ID
+String sessionId = message.getSessionId(); // 会话ID
+String content = message.getContent(); // 消息内容
+String fromUser = message.getFromUserName(); // 发送用户
+
+// 处理消息并回复
+// ...
+```
+
### 删除智能机器人
```java
@@ -87,13 +123,19 @@ robotService.deleteRobot(robotId);
- `WxCpIntelligentRobotCreateRequest`: 创建机器人请求
- `WxCpIntelligentRobotUpdateRequest`: 更新机器人请求
- `WxCpIntelligentRobotChatRequest`: 智能对话请求
+- `WxCpIntelligentRobotSendMessageRequest`: 主动发送消息请求
### 响应类
- `WxCpIntelligentRobotCreateResponse`: 创建机器人响应
- `WxCpIntelligentRobotChatResponse`: 智能对话响应
+- `WxCpIntelligentRobotSendMessageResponse`: 主动发送消息响应
- `WxCpIntelligentRobot`: 机器人信息实体
+### 消息接收
+
+- `WxCpXmlMessage`: 支持接收智能机器人回调消息,包含 `robotId` 和 `sessionId` 字段
+
### 服务接口
- `WxCpIntelligentRobotService`: 智能机器人服务接口
diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml
index 00a6b2d06c..6f8ab756a0 100644
--- a/weixin-java-cp/pom.xml
+++ b/weixin-java-cp/pom.xml
@@ -7,7 +7,7 @@
com.github.binarywang
wx-java
- 4.7.9.B
+ 4.8.0
weixin-java-cp
@@ -30,6 +30,11 @@
okhttp
provided
+
+ org.apache.httpcomponents
+ httpclient
+ provided
+
org.apache.httpcomponents.client5
httpclient5
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpAgentService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpAgentService.java
index 9eddc0f507..05f06f1da9 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpAgentService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpAgentService.java
@@ -2,6 +2,7 @@
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.bean.WxCpAgent;
+import me.chanjar.weixin.cp.bean.WxCpTpAdmin;
import java.util.List;
@@ -52,4 +53,18 @@ public interface WxCpAgentService {
*/
List list() throws WxErrorException;
+ /**
+ *
+ * 获取应用管理员列表
+ * 第三方服务商可以用此接口获取授权企业中某个第三方应用或者代开发应用的管理员列表(不包括外部管理员),
+ * 以便服务商在用户进入应用主页之后根据是否管理员身份做权限的区分。
+ * 详情请见: 文档
+ *
+ *
+ * @param agentId 应用id
+ * @return admin list
+ * @throws WxErrorException the wx error exception
+ */
+ WxCpTpAdmin getAdminList(Integer agentId) throws WxErrorException;
+
}
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpCorpGroupService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpCorpGroupService.java
index 4da13d3fde..69aea4bca7 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpCorpGroupService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpCorpGroupService.java
@@ -9,7 +9,7 @@
* 企业互联相关接口
*
* @author libo <422423229@qq.com>
- * Created on 27/2/2023 9:57 PM
+ * @since 2023-02-27 9:57 PM
*/
public interface WxCpCorpGroupService {
/**
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExportService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExportService.java
index 24c6ea9dc1..a2c7adabea 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExportService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExportService.java
@@ -85,7 +85,7 @@ public interface WxCpExportService {
* 获取导出结果
*
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/export/get_result?access_token=ACCESS_TOKEN&jobid=jobid_xxxxxxxxxxxxxxx
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/export/get_result?access_token=ACCESS_TOKEN&jobid=jobid_xxxxxxxxxxxxxxx}
*
* 文档地址:https://developer.work.weixin.qq.com/document/path/94854
* 返回的url文件下载解密可参考 CSDN
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java
index 7f3cdeab7c..6de9f9226d 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java
@@ -146,7 +146,7 @@ public interface WxCpExternalContactService {
* 企业可通过此接口,根据外部联系人的userid(如何获取?),拉取客户详情。
*
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=ACCESS_TOKEN&external_userid=EXTERNAL_USERID
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=ACCESS_TOKEN&external_userid=EXTERNAL_USERID}
*
* 权限说明:
*
@@ -252,9 +252,9 @@ public interface WxCpExternalContactService {
*
* 权限说明:
*
- * 该企业授权了该服务商第三方应用,且授权的第三方应用具备“企业客户权限->客户基础信息”权限
+ * {@code 该企业授权了该服务商第三方应用,且授权的第三方应用具备“企业客户权限->客户基础信息”权限}
* 该客户的跟进人必须在应用的可见范围之内
- * 应用需具备“企业客户权限->客户基础信息”权限
+ * {@code 应用需具备“企业客户权限->客户基础信息”权限}
*
*
* @param externalUserid 代开发自建应用获取到的外部联系人ID
@@ -276,8 +276,8 @@ public interface WxCpExternalContactService {
*
* @param externalUserid 服务商主体的external_userid,必须是source_agentid对应的应用所获取
* @param sourceAgentId 企业授权的代开发自建应用或第三方应用的agentid
- * @return
- * @throws WxErrorException
+ * @return 企业的external_userid
+ * @throws WxErrorException 微信错误异常
*/
String fromServiceExternalUserid(String externalUserid, String sourceAgentId) throws WxErrorException;
@@ -362,7 +362,7 @@ public interface WxCpExternalContactService {
* 权限说明:
*
* 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)
- * 第三方应用需具有“企业客户权限->客户基础信息”权限
+ * {@code 第三方应用需具有“企业客户权限->客户基础信息”权限}
* 对于第三方/自建应用,群主必须在应用的可见范围
* 仅支持企业服务人员创建的客户群
* 仅可转换出自己企业下的客户群chat_id
@@ -410,11 +410,12 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c
* 文档地址: https://developer.work.weixin.qq.com/document/path/99434
*
*
+ * 注意:企业可通过外部联系人临时ID排除重复数据,外部联系人临时ID有效期为4小时。
+ *
* @param cursor the cursor
* @param limit the limit
* @return 已服务的外部联系人列表
* @throws WxErrorException .
- * @apiNote 企业可通过外部联系人临时ID排除重复数据,外部联系人临时ID有效期为4小时。
*/
WxCpExternalContactListInfo getContactList(String cursor, Integer limit) throws WxErrorException;
@@ -438,7 +439,7 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c
* 企业可通过此接口获取指定成员添加的客户列表。客户是指配置了客户联系功能的成员所添加的外部联系人。没有配置客户联系功能的成员,所添加的外部联系人将不会作为客户返回。
*
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list?access_token=ACCESS_TOKEN&userid=USERID
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list?access_token=ACCESS_TOKEN&userid=USERID}
*
* 权限说明:
*
@@ -469,7 +470,8 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c
/**
* 获取待分配的离职成员列表
* 企业和第三方可通过此接口,获取所有离职成员的客户列表,并可进一步调用分配离职成员的客户接口将这些客户重新分配给其他企业成员。
- *
+
+ *
* 请求方式:POST(HTTPS)
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_unassigned_list?access_token=ACCESS_TOKEN
*
@@ -496,17 +498,17 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c
/**
* 企业可通过此接口,转接在职成员的客户给其他成员。
- *
+ *
* 权限说明:
- * * 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。
- * 第三方应用需拥有“企业客户权限->客户联系->在职继承”权限
+ * 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。
+ * {@code 第三方应用需拥有“企业客户权限->客户联系->在职继承”权限}
* 接替成员必须在此第三方应用或自建应用的可见范围内。
* 接替成员需要配置了客户联系功能。
* 接替成员需要在企业微信激活且已经过实名认证。
- *
+ *
* 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。
- * 第三方应用需拥有“企业客户权限->客户联系->在职继承”权限
+ * {@code 第三方应用需拥有“企业客户权限->客户联系->在职继承”权限}
* 接替成员必须在此第三方应用或自建应用的可见范围内。
- *
+
+ *
* 权限说明:
- *
+
+ *
* 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。
- * 第三方应用需拥有“企业客户权限->客户联系->离职分配”权限
+ * {@code 第三方应用需拥有“企业客户权限->客户联系->离职分配”权限}
* 接替成员必须在此第三方应用或自建应用的可见范围内。
* 接替成员需要配置了客户联系功能。
* 接替成员需要在企业微信激活且已经过实名认证。
- *
+
+ *
* 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。
- * 第三方应用需拥有“企业客户权限->客户联系->在职继承”权限
+ * {@code 第三方应用需拥有“企业客户权限->客户联系->在职继承”权限}
* 接替成员必须在此第三方应用或自建应用的可见范围内。
- *
+
+ *
* 群主离职了的客户群,才可继承
* 继承给的新群主,必须是配置了客户联系功能的成员
* 继承给的新群主,必须有设置实名
* 继承给的新群主,必须有激活企业微信
* 同一个人的群,限制每天最多分配300个给新群主
- *
+
+ *
* 权限说明:
- *
+
+ *
* 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。
- * 第三方应用需拥有“企业客户权限->客户联系->分配离职成员的客户群”权限
+ * {@code 第三方应用需拥有“企业客户权限->客户联系->分配离职成员的客户群”权限}
* 对于第三方/自建应用,群主必须在应用的可见范围。
- *
+
+ *
* 请求方式: POST(HTTP)
- *
+
+ *
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_msg_template?access_token=ACCESS_TOKEN
- *
+
+ *
* 文档地址
*
* @param wxCpMsgTemplate the wx cp msg template
@@ -733,15 +744,18 @@ WxCpUserExternalGroupChatStatistic getGroupChatStatistic(Date startTime, Integer
/**
* 提醒成员群发
* 企业和第三方应用可调用此接口,重新触发群发通知,提醒成员完成群发任务,24小时内每个群发最多触发三次提醒。
- *
+
+ *
* 请求方式: POST(HTTPS)
- *
+
+ *
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/remind_groupmsg_send?access_token=ACCESS_TOKEN
- *
+ *
* 文档地址
*
* @param msgId 群发消息的id,通过获取群发记录列表接口返回
* @return the wx cp msg template add result
+ * @throws WxErrorException 微信错误异常
*/
WxCpBaseResp remindGroupMsgSend(String msgId) throws WxErrorException;
@@ -753,11 +767,12 @@ WxCpUserExternalGroupChatStatistic getGroupChatStatistic(Date startTime, Integer
* 请求方式: POST(HTTPS)
*
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/cancel_groupmsg_send?access_token=ACCESS_TOKEN
- *
+ *
* 文档地址
*
* @param msgId 群发消息的id,通过获取群发记录列表接口返回
* @return the wx cp msg template add result
+ * @throws WxErrorException 微信错误异常
*/
WxCpBaseResp cancelGroupMsgSend(String msgId) throws WxErrorException;
@@ -1002,7 +1017,7 @@ WxCpGroupMsgListResult getGroupMsgListV2(String chatType, Date startTime, Date e
/**
*
+ *
+ *
+ * 注意:
+ * 1.批量更新请求中的各个操作会逐个按顺序执行,直到全部执行完成则请求返回,或者其中一个操作报错则不再继续执行后续的操作
+ * 2.每一个更新操作在执行之前都会做请求校验(包括权限校验、参数校验等等),如果校验未通过则该更新操作会报错并返回,不再执行后续操作
+ * 3.单次批量更新请求的操作数量 <= 5
+ *
+ * 请求方式:POST(HTTPS)
+ * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedoc/spreadsheet/batch_update?access_token=ACCESS_TOKEN
+ *
+ * @param request 编辑表格内容请求参数
+ * @return 编辑表格内容批量更新的响应结果
+ * @throws WxErrorException the wx error exception
+ */
+ WxCpDocSheetBatchUpdateResponse docBatchUpdate(@NonNull WxCpDocSheetBatchUpdateRequest request) throws WxErrorException;
+
+ /**
+ * 获取表格行列信息
+ * 该接口用于获取在线表格的工作表、行数、列数等。
+ *
+ * 请求方式:POST(HTTPS)
+ * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedoc/spreadsheet/get_sheet_properties?access_token=ACCESS_TOKEN
+ *
+ * @param docId 在线表格的docid
+ * @return 返回表格行列信息
+ * @throws WxErrorException
+ */
+ WxCpDocSheetProperties getSheetProperties(@NonNull String docId) throws WxErrorException;
+
+
+ /**
+ * 本接口用于获取指定范围内的在线表格信息,单次查询的范围大小需满足以下限制:
+ *
+ * 查询范围行数 <=1000
+ * 查询范围列数 <=200
+ * 范围内的总单元格数量 <=10000
+ *
+ * 请求方式:POST(HTTPS)
+ * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedoc/spreadsheet/get_sheet_range_data?access_token=ACCESS_TOKEN
+ *
+ * @param request 获取指定范围内的在线表格信息请求参数
+ * @return 返回指定范围内的在线表格信息
+ * @throws WxErrorException
+ */
+ WxCpDocSheetData getSheetRangeData(@NonNull WxCpDocSheetGetDataRequest request) throws WxErrorException;
+
}
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolService.java
index 56687c9cb1..5f1d41c197 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolService.java
@@ -80,9 +80,10 @@ public interface WxCpSchoolService {
/**
* 获取直播详情
+ *
+ *
+ *
+ *
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=ACCESS_TOKEN&external_userid
- * =EXTERNAL_USERID
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=ACCESS_TOKEN&external_userid=EXTERNAL_USERID}
*
* @param externalUserId 外部联系人的userid,注意不是学校成员的帐号
* @return external contact
@@ -306,9 +315,9 @@ WxCpBaseResp updateStudent(@NonNull String studentUserId, String newStudentUserI
/**
* 获取可使用的家长范围
* 获取可在微信「学校通知-学校应用」使用该应用的家长范围,以学生或部门列表的形式返回。应用只能给该列表下的家长发送「学校通知」。注意该范围只能由学校的系统管理员在「管理端-家校沟通-配置」配置。
- *
+ *
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/agent/get_allow_scope?access_token=ACCESS_TOKEN&agentid=AGENTID
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/agent/get_allow_scope?access_token=ACCESS_TOKEN&agentid=AGENTID}
*
* @param agentId the agent id
* @return allow scope
@@ -332,7 +341,7 @@ WxCpBaseResp updateStudent(@NonNull String studentUserId, String newStudentUserI
/**
* 获取部门列表
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/department/list?access_token=ACCESS_TOKEN&id=ID
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/department/list?access_token=ACCESS_TOKEN&id=ID}
*
* @param id 部门id。获取指定部门及其下的子部门。 如果不填,默认获取全量组织架构
* @return wx cp department list
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java
index 0b601ca502..76012a2812 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java
@@ -584,7 +584,7 @@ public interface WxCpService extends WxService {
/**
* 企业互联的服务类对象
*
- * @return
+ * @return 企业互联服务对象
*/
WxCpCorpGroupService getCorpGroupService();
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpUserService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpUserService.java
index 2368386b23..7a7b5f40a8 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpUserService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpUserService.java
@@ -38,7 +38,7 @@ public interface WxCpUserService {
*
- * Created by songfan on 2020/7/14.
*
- * @author songfan & Mr.Pan
+ * @author songfan, Mr.Pan
+ * @since 2020/7/14
*/
@Data
@Builder
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalUnassignList.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalUnassignList.java
index 8605760fa7..f3fdd96ce7 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalUnassignList.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpUserExternalUnassignList.java
@@ -12,7 +12,8 @@
/**
* 离职员工外部联系人列表
*
- * @author yqx & Wang_Wong created on 2020/3/15
+ * @author yqx, Wang_Wong
+ * @since 2020/3/15
*/
@Getter
@Setter
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionStatistic.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionStatistic.java
index bb02b039bd..87e3d5580a 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionStatistic.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionStatistic.java
@@ -10,7 +10,7 @@
* 获客链接的使用详情
*
* @author Hugo
- * @date 2023/12/11 10:31
+ * @since 2023/12/11 10:31
*/
@Data
@EqualsAndHashCode(callSuper = true)
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRuleInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRuleInfo.java
index 20d6b32442..23bb70a240 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRuleInfo.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRuleInfo.java
@@ -10,9 +10,10 @@
import java.util.List;
/**
- * @Date: 2024-03-07 17:02
- * @Author: shenliuming
- * @return:
+ * 防骚扰规则详情
+ *
+ * @author shenliuming
+ * @since 2024-03-07 17:02
*/
@Data
@EqualsAndHashCode(callSuper = true)
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRuleList.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRuleList.java
index 6826413e13..543d32fcb9 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRuleList.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/interceptrule/WxCpInterceptRuleList.java
@@ -9,9 +9,10 @@
import java.util.List;
/**
- * @Date: 2024-03-07 15:54
- * @Author: shenliuming
- * @return:
+ * 防骚扰规则列表
+ *
+ * @author shenliuming
+ * @since 2024-03-07 15:54
*/
@Data
@EqualsAndHashCode(callSuper = true)
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Attachment.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Attachment.java
index be9dcc9dd0..1fff457f97 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Attachment.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Attachment.java
@@ -33,6 +33,7 @@ public class Attachment implements Serializable {
* Sets image.
*
* @param image the image
+ * @return this
*/
public Attachment setImage(Image image) {
this.image = image;
@@ -44,6 +45,7 @@ public Attachment setImage(Image image) {
* Sets link.
*
* @param link the link
+ * @return this
*/
public Attachment setLink(Link link) {
this.link = link;
@@ -55,6 +57,7 @@ public Attachment setLink(Link link) {
* Sets mini program.
*
* @param miniProgram the mini program
+ * @return this
*/
public Attachment setMiniProgram(MiniProgram miniProgram) {
this.miniProgram = miniProgram;
@@ -66,6 +69,7 @@ public Attachment setMiniProgram(MiniProgram miniProgram) {
* Sets video.
*
* @param video the video
+ * @return this
*/
public Attachment setVideo(Video video) {
this.video = video;
@@ -77,6 +81,7 @@ public Attachment setVideo(Video video) {
* Sets file.
*
* @param file the file
+ * @return this
*/
public Attachment setFile(File file) {
this.file = file;
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/intelligentrobot/WxCpIntelligentRobotSendMessageRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/intelligentrobot/WxCpIntelligentRobotSendMessageRequest.java
new file mode 100644
index 0000000000..405c67daff
--- /dev/null
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/intelligentrobot/WxCpIntelligentRobotSendMessageRequest.java
@@ -0,0 +1,56 @@
+package me.chanjar.weixin.cp.bean.intelligentrobot;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
+
+import java.io.Serializable;
+
+/**
+ * 智能机器人发送消息请求
+ * 官方文档: https://developer.work.weixin.qq.com/document/path/100719
+ *
+ * @author Binary Wang
+ */
+@Data
+public class WxCpIntelligentRobotSendMessageRequest implements Serializable {
+ private static final long serialVersionUID = -1L;
+
+ /**
+ * 机器人ID,必填
+ */
+ @SerializedName("robot_id")
+ private String robotId;
+
+ /**
+ * 接收消息的用户ID,必填
+ */
+ @SerializedName("userid")
+ private String userid;
+
+ /**
+ * 消息内容,必填
+ */
+ @SerializedName("message")
+ private String message;
+
+ /**
+ * 会话ID,可选,用于保持会话连续性
+ */
+ @SerializedName("session_id")
+ private String sessionId;
+
+ /**
+ * 消息ID,可选
+ */
+ @SerializedName("msg_id")
+ private String msgId;
+
+ public String toJson() {
+ return WxCpGsonBuilder.create().toJson(this);
+ }
+
+ public static WxCpIntelligentRobotSendMessageRequest fromJson(String json) {
+ return WxCpGsonBuilder.create().fromJson(json, WxCpIntelligentRobotSendMessageRequest.class);
+ }
+}
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/intelligentrobot/WxCpIntelligentRobotSendMessageResponse.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/intelligentrobot/WxCpIntelligentRobotSendMessageResponse.java
new file mode 100644
index 0000000000..8098d2037e
--- /dev/null
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/intelligentrobot/WxCpIntelligentRobotSendMessageResponse.java
@@ -0,0 +1,42 @@
+package me.chanjar.weixin.cp.bean.intelligentrobot;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import me.chanjar.weixin.cp.bean.WxCpBaseResp;
+import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
+
+import java.io.Serializable;
+
+/**
+ * 智能机器人发送消息响应
+ * 官方文档: https://developer.work.weixin.qq.com/document/path/100719
+ *
+ * @author Binary Wang
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class WxCpIntelligentRobotSendMessageResponse extends WxCpBaseResp implements Serializable {
+ private static final long serialVersionUID = -1L;
+
+ /**
+ * 消息ID
+ */
+ @SerializedName("msg_id")
+ private String msgId;
+
+ /**
+ * 会话ID
+ */
+ @SerializedName("session_id")
+ private String sessionId;
+
+ public static WxCpIntelligentRobotSendMessageResponse fromJson(String json) {
+ return WxCpGsonBuilder.create().fromJson(json, WxCpIntelligentRobotSendMessageResponse.class);
+ }
+
+ @Override
+ public String toJson() {
+ return WxCpGsonBuilder.create().toJson(this);
+ }
+}
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountLink.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountLink.java
index a903d0fa54..38d25e61cd 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountLink.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/kf/WxCpKfAccountLink.java
@@ -27,10 +27,10 @@ public class WxCpKfAccountLink implements Serializable {
* 场景值,字符串类型,由开发者自定义。
* 不多于32字节
* 字符串取值范围(正则表达式):[0-9a-zA-Z_-]*
- *
+ *
* 1. 若scene非空,返回的客服链接开发者可拼接scene_param=SCENE_PARAM参数使用,用户进入会话事件会将SCENE_PARAM原样返回。
* 其中SCENE_PARAM需要urlencode,且长度不能超过128字节。
- * 如 https://work.weixin.qq.com/kf/kfcbf8f8d07ac7215f?enc_scene=ENCGFSDF567DF&scene_param=a%3D1%26b%3D2
+ * {@code 如 https://work.weixin.qq.com/kf/kfcbf8f8d07ac7215f?enc_scene=ENCGFSDF567DF&scene_param=a%3D1%26b%3D2}
* 2. 历史调用接口返回的客服链接(包含encScene=XXX参数),不支持scene_param参数。
* 3. 返回的客服链接,不能修改或复制参数到其他链接使用。否则进入会话事件参数校验不通过,导致无法回调。
*/
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/media/MediaUploadByUrlReq.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/media/MediaUploadByUrlReq.java
index c5cb21bde5..0149a426f6 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/media/MediaUploadByUrlReq.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/media/MediaUploadByUrlReq.java
@@ -5,8 +5,9 @@
/**
* 生成异步上传任务
+ *
* @author imyzt
- * @date 2025/04/27
+ * @since 2025/04/27
*/
@Data
public class MediaUploadByUrlReq {
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/media/MediaUploadByUrlResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/media/MediaUploadByUrlResult.java
index cc931eed39..595f85dffa 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/media/MediaUploadByUrlResult.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/media/MediaUploadByUrlResult.java
@@ -10,8 +10,9 @@
/**
* 异步上传企微素材
+ *
* @author imyzt
- * @date 2025/4/27
+ * @since 2025/4/27
*/
@EqualsAndHashCode(callSuper = true)
@Data
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessage.java
index 92209fd4e5..7e777384eb 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessage.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessage.java
@@ -85,13 +85,13 @@ public class WxCpLinkedCorpMessage implements Serializable {
/**
*
* 文档地址
- *
* external_userid必须是handover_userid的客户(即配置了客户联系功能的成员所添加的联系人)。
* 在职成员的每位客户最多被分配2次。客户被转接成功后,将有90个自然日的服务关系保护期,保护期内的客户无法再次被分配。
- *
* 权限说明:
- *
* handover_userid必须是已离职用户。
* external_userid必须是handover_userid的客户(即配置了客户联系功能的成员所添加的联系人)。
* 在职成员的每位客户最多被分配2次。客户被转接成功后,将有90个自然日的服务关系保护期,保护期内的客户无法再次被分配。
- *
* 权限说明:
- *
* 注意::
- *
* 注意:
* 继承给的新群主,必须是配置了客户联系功能的成员
* 继承给的新群主,必须有设置实名
@@ -716,11 +724,14 @@ WxCpUserExternalGroupChatStatistic getGroupChatStatistic(Date startTime, Integer
* 企业可通过此接口添加企业群发消息的任务并通知客服人员发送给相关客户或客户群。(注:企业微信终端需升级到2.7.5版本及以上)
* 注意:调用该接口并不会直接发送消息给客户/客户群,需要相关的客服人员操作以后才会实际发送(客服人员的企业微信需要升级到2.7.5及以上版本)
* 同一个企业每个自然月内仅可针对一个客户/客户群发送4条消息,超过限制的用户将会被忽略。
- *
*
* @param mediaId 媒体id
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMessageService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMessageService.java
index e49a36ba50..534cc89b36 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMessageService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMessageService.java
@@ -72,8 +72,9 @@ public interface WxCpMessageService {
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/message/recall?access_token=ACCESS_TOKEN
* 文档地址: https://developer.work.weixin.qq.com/document/path/94867
*
+ *
* @param msgId 消息id
- * @throws WxErrorException
+ * @throws WxErrorException 异常
*/
void recall(String msgId) throws WxErrorException;
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOAuth2Service.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOAuth2Service.java
index b7a44047aa..1824196720 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOAuth2Service.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOAuth2Service.java
@@ -90,9 +90,10 @@ public interface WxCpOAuth2Service {
/**
* 获取家校访问用户身份
* 该接口用于根据code获取家长或者学生信息
- *
* 企业和第三方应用可通过此接口获取企业与成员的群发记录。
- * 获取企业群发成员执行结果
+ * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/93338
*
*
* @param msgid 群发消息的id,通过获取群发记录列表接口返回
@@ -1031,7 +1046,7 @@ WxCpGroupMsgListResult getGroupMsgListV2(String chatType, Date startTime, Date e
/**
*
* 获取群发成员发送任务列表。
- * 获取群发成员发送任务列表
+ * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/93338
*
*
* @param msgid 群发消息的id,通过获取群发记录列表接口返回
@@ -1045,7 +1060,7 @@ WxCpGroupMsgListResult getGroupMsgListV2(String chatType, Date startTime, Date e
/**
*
* 添加入群欢迎语素材。
- * 添加入群欢迎语素材
+ * 文档地址:https://open.work.weixin.qq.com/api/doc/90000/90135/92366
*
*
* @param template 素材内容
@@ -1057,7 +1072,7 @@ WxCpGroupMsgListResult getGroupMsgListV2(String chatType, Date startTime, Date e
/**
*
* 编辑入群欢迎语素材。
- * 编辑入群欢迎语素材
+ * 文档地址:https://open.work.weixin.qq.com/api/doc/90000/90135/92366
*
*
* @param template the template
@@ -1069,7 +1084,7 @@ WxCpGroupMsgListResult getGroupMsgListV2(String chatType, Date startTime, Date e
/**
*
* 获取入群欢迎语素材。
- * 获取入群欢迎语素材
+ * 文档地址:https://open.work.weixin.qq.com/api/doc/90000/90135/92366
*
*
* @param templateId 群欢迎语的素材id
@@ -1082,7 +1097,7 @@ WxCpGroupMsgListResult getGroupMsgListV2(String chatType, Date startTime, Date e
*
* 删除入群欢迎语素材。
* 企业可通过此API删除入群欢迎语素材,且仅能删除调用方自己创建的入群欢迎语素材。
- * 删除入群欢迎语素材
+ * 文档地址:https://open.work.weixin.qq.com/api/doc/90000/90135/92366
*
*
* @param templateId 群欢迎语的素材id
@@ -1094,8 +1109,8 @@ WxCpGroupMsgListResult getGroupMsgListV2(String chatType, Date startTime, Date e
/**
*
- * 获取商品图册
- * 获取商品图册列表
+ * 获取商品图册列表
+ * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/95096
*
*
* @param limit 返回的最大记录数,整型,最大值100,默认值50,超过最大值时取默认值
@@ -1108,7 +1123,7 @@ WxCpGroupMsgListResult getGroupMsgListV2(String chatType, Date startTime, Date e
/**
*
* 获取商品图册
- * 获取商品图册
+ * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/95096
*
*
* @param productId 商品id
@@ -1155,7 +1170,7 @@ WxMediaUploadResult uploadAttachment(String mediaType, Integer attachmentType, F
* 企业和第三方应用可以通过此接口新建敏感词规则
* 请求方式:POST(HTTPS)
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_intercept_rule?access_token=ACCESS_TOKEN
- *
+ *
* @param ruleAddRequest the rule add request
* @return 规则id
* @throws WxErrorException the wx error exception
@@ -1169,7 +1184,7 @@ WxMediaUploadResult uploadAttachment(String mediaType, Integer attachmentType, F
* 企业和第三方应用可以通过此接口修改敏感词规则
* 请求方式:POST(HTTPS)
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/update_intercept_rule?access_token=ACCESS_TOKEN
- *
+ *
* @param interceptRule the rule
* @throws WxErrorException the wx error exception
*/
@@ -1181,7 +1196,7 @@ WxMediaUploadResult uploadAttachment(String mediaType, Integer attachmentType, F
* 企业和第三方应用可以通过此接口修改敏感词规则
* 请求方式:POST(HTTPS)
* 请求地址
- *
+ *
* @param ruleId 规则id
* @throws WxErrorException the wx error exception
*/
@@ -1220,7 +1235,7 @@ WxMediaUploadResult uploadAttachment(String mediaType, Integer attachmentType, F
* 请求地址:
* https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_product_album?access_token=ACCESS_TOKEN
* 文档地址
- *
+ *
* @param wxCpProductAlbumInfo 商品图册信息
* @return 商品id string
* @throws WxErrorException the wx error exception
@@ -1235,7 +1250,7 @@ WxMediaUploadResult uploadAttachment(String mediaType, Integer attachmentType, F
* 请求地址:
* https://qyapi.weixin.qq.com/cgi-bin/externalcontact/update_product_album?access_token=ACCESS_TOKEN
* 文档地址
- *
+ *
* @param wxCpProductAlbumInfo 商品图册信息
* @throws WxErrorException the wx error exception
*/
@@ -1250,7 +1265,7 @@ WxMediaUploadResult uploadAttachment(String mediaType, Integer attachmentType, F
* https://qyapi.weixin.qq.com/cgi-bin/externalcontact/delete_product_album?access_token=ACCESS_TOKEN
*
* 文档地址
- *
+ *
* @param productId 商品id
* @throws WxErrorException the wx error exception
*/
@@ -1379,7 +1394,7 @@ WxMediaUploadResult uploadAttachment(String mediaType, Integer attachmentType, F
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition/statistic?access_token=ACCESS_TOKEN
*
* @author Hugo
- * @date 2023/12/5 14:34
+ * @since 2023/12/5 14:34
* @param linkId 获客链接的id
* @param startTime 统计起始时间
* @param endTime 统计结束时间
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpGroupRobotService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpGroupRobotService.java
index c1a8d56255..b8ccea5e50 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpGroupRobotService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpGroupRobotService.java
@@ -126,9 +126,10 @@ public interface WxCpGroupRobotService {
/**
* 发送模板卡片消息
- * @param webhookUrl
- * @param wxCpGroupRobotMessage
- * @throws WxErrorException
+ *
+ * @param webhookUrl webhook地址
+ * @param wxCpGroupRobotMessage 群机器人消息
+ * @throws WxErrorException 异常
*/
void sendTemplateCardMessage(String webhookUrl, WxCpGroupRobotMessage wxCpGroupRobotMessage) throws WxErrorException;
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpIntelligentRobotService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpIntelligentRobotService.java
index f68092918f..bc5f3f1915 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpIntelligentRobotService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpIntelligentRobotService.java
@@ -64,4 +64,14 @@ public interface WxCpIntelligentRobotService {
*/
void resetSession(String robotId, String userid, String sessionId) throws WxErrorException;
+ /**
+ * 智能机器人主动发送消息
+ * 官方文档: https://developer.work.weixin.qq.com/document/path/100719
+ *
+ * @param request 发送消息请求参数
+ * @return 发送消息响应
+ * @throws WxErrorException 微信接口异常
+ */
+ WxCpIntelligentRobotSendMessageResponse sendMessage(WxCpIntelligentRobotSendMessageRequest request) throws WxErrorException;
+
}
\ No newline at end of file
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpKfService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpKfService.java
index 5a53829dc0..046cfbc5bb 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpKfService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpKfService.java
@@ -222,7 +222,7 @@ WxCpKfCustomerBatchGetResp customerBatchGet(List
+ *
* @param request 查询参数
* @return 客户数据统计 -企业汇总数据
* @throws WxErrorException the wx error exception
@@ -238,7 +238,7 @@ WxCpKfCustomerBatchGetResp customerBatchGet(List
+ *
* @param request 查询参数
* @return 客户数据统计 -企业汇总数据
* @throws WxErrorException the wx error exception
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpLivingService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpLivingService.java
index a2e2344190..63fabad7a1 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpLivingService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpLivingService.java
@@ -27,7 +27,7 @@ public interface WxCpLivingService {
/**
* 获取直播详情
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/living/get_living_info?access_token=ACCESS_TOKEN&livingid=LIVINGID
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/living/get_living_info?access_token=ACCESS_TOKEN&livingid=LIVINGID}
*
* @param livingId 直播id
* @return 获取的直播详情 living info
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMediaService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMediaService.java
index e874b26f42..dd5ce594b2 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMediaService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMediaService.java
@@ -110,9 +110,9 @@ WxMediaUploadResult upload(String mediaType, String filename, String url)
* 获取高清语音素材.
* 可以使用本接口获取从JSSDK的uploadVoice接口上传的临时语音素材,格式为speex,16K采样率。该音频比上文的临时素材获取接口(格式为amr,8K采样率)更加清晰,适合用作语音识别等对音质要求较高的业务。
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/media/get/jssdk?access_token=ACCESS_TOKEN&media_id=MEDIA_ID
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/media/get/jssdk?access_token=ACCESS_TOKEN&media_id=MEDIA_ID}
* 仅企业微信2.4及以上版本支持。
- * 文档地址:https://work.weixin.qq.com/api/doc#90000/90135/90255
+ * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/90255
*
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/getuserinfo?access_token=ACCESS_TOKEN&code=CODE
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/getuserinfo?access_token=ACCESS_TOKEN&code=CODE}
+ *
*
* @param code the code
* @return school user info
@@ -123,7 +124,7 @@ public interface WxCpOAuth2Service {
/**
*
* 获取用户登录身份
- * https://qyapi.weixin.qq.com/cgi-bin/auth/getuserinfo?access_token=ACCESS_TOKEN&code=CODE
+ * {@code https://qyapi.weixin.qq.com/cgi-bin/auth/getuserinfo?access_token=ACCESS_TOKEN&code=CODE}
* 该接口可使用用户登录成功颁发的code来获取成员信息,适用于自建应用与代开发应用
*
* 注意: 旧的/user/getuserinfo 接口的url已变更为auth/getuserinfo,不过旧接口依旧可以使用,建议是关注新接口即可
@@ -140,13 +141,15 @@ public interface WxCpOAuth2Service {
/**
* 获取用户二次验证信息
- *
*
* @param wxCpOaMeetingRoomBookingInfoRequest 会议室预定信息查询对象
+ * @return 会议室预定信息
* @throws WxErrorException .
*/
WxCpOaMeetingRoomBookingInfoResult getMeetingRoomBookingInfo(WxCpOaMeetingRoomBookingInfoRequest wxCpOaMeetingRoomBookingInfoRequest) throws WxErrorException;
@@ -99,6 +100,7 @@ public interface WxCpOaMeetingRoomService {
*
*
* @param wxCpOaMeetingRoomBookRequest 会议室预定对象
+ * @return 预定结果
* @throws WxErrorException .
*/
WxCpOaMeetingRoomBookResult bookingMeetingRoom(WxCpOaMeetingRoomBookRequest wxCpOaMeetingRoomBookRequest) throws WxErrorException;
@@ -114,6 +116,7 @@ public interface WxCpOaMeetingRoomService {
*
*
* @param wxCpOaMeetingRoomBookByScheduleRequest 会议室预定对象
+ * @return 预定结果
* @throws WxErrorException .
*/
WxCpOaMeetingRoomBookResult bookingMeetingRoomBySchedule(WxCpOaMeetingRoomBookByScheduleRequest wxCpOaMeetingRoomBookByScheduleRequest) throws WxErrorException;
@@ -129,6 +132,7 @@ public interface WxCpOaMeetingRoomService {
*
*
* @param wxCpOaMeetingRoomBookByMeetingRequest 会议室预定对象
+ * @return 预定结果
* @throws WxErrorException .
*/
WxCpOaMeetingRoomBookResult bookingMeetingRoomByMeeting(WxCpOaMeetingRoomBookByMeetingRequest wxCpOaMeetingRoomBookByMeetingRequest) throws WxErrorException;
@@ -147,10 +151,10 @@ public interface WxCpOaMeetingRoomService {
* @param wxCpOaMeetingRoomCancelBookRequest 取消预定会议室对象
* @throws WxErrorException .
*/
- void cancelBookMeetingRoom(WxCpOaMeetingRoomCancelBookRequest wxCpOaMeetingRoomCancelBookRequest) throws WxErrorException;
+ void cancelBookMeetingRoom(WxCpOaMeetingRoomCancelBookRequest wxCpOaMeetingRoomCancelBookRequest) throws WxErrorException;
- /**
+ /**
* 根据会议室预定ID查询预定详情.
*
* api: https://qyapi.weixin.qq.com/cgi-bin/auth/get_tfa_info?access_token=ACCESS_TOKEN
* 权限说明:仅『通讯录同步』或者自建应用可调用,如用自建应用调用,用户需要在二次验证范围和应用可见范围内。
* 并发限制:20
+ *
*
* @param code 用户进入二次验证页面时,企业微信颁发的code,每次成员授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期
- * @return me.chanjar.weixin.cp.bean.workbench.WxCpSecondVerificationInfo 二次验证授权码,开发者可以调用通过二次验证接口,解锁企业微信终端.tfa_code有效期五分钟,且只能使用一次。
+ * @return 二次验证授权码,开发者可以调用通过二次验证接口,解锁企业微信终端.tfa_code有效期五分钟,且只能使用一次。
+ * @throws WxErrorException 微信错误异常
*/
WxCpSecondVerificationInfo getTfaInfo(String code) throws WxErrorException;
}
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaMeetingRoomService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaMeetingRoomService.java
index c2e6c5c872..cc039fd9f5 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaMeetingRoomService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaMeetingRoomService.java
@@ -84,6 +84,7 @@ public interface WxCpOaMeetingRoomService {
*
* 企业可通过此接口根据预定id查询相关会议室的预定情况
@@ -161,8 +165,9 @@ public interface WxCpOaMeetingRoomService {
*
*
* @param wxCpOaMeetingRoomBookingInfoByBookingIdRequest 根据会议室预定ID查询预定详情对象
+ * @return 预定详情
* @throws WxErrorException .
*/
- WxCpOaMeetingRoomBookingInfoByBookingIdResult getBookingInfoByBookingId(WxCpOaMeetingRoomBookingInfoByBookingIdRequest wxCpOaMeetingRoomBookingInfoByBookingIdRequest) throws WxErrorException;
+ WxCpOaMeetingRoomBookingInfoByBookingIdResult getBookingInfoByBookingId(WxCpOaMeetingRoomBookingInfoByBookingIdRequest wxCpOaMeetingRoomBookingInfoByBookingIdRequest) throws WxErrorException;
}
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java
index ee57107b5c..3494dcfa4e 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java
@@ -11,7 +11,8 @@
/**
* 企业微信OA相关接口.
*
- * @author Element & Wang_Wong created on 2019-04-06 10:52
+ * @author Element, Wang_Wong
+ * @since 2019-04-06 10:52
*/
public interface WxCpOaService {
@@ -331,7 +332,7 @@ List
+ *
* @param userId 需要录入的用户id
* @param userFace 需要录入的人脸图片数据,需要将图片数据base64处理后填入,对已录入的人脸会进行更新处理
* @throws WxErrorException the wx error exception
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDocService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDocService.java
index 1356c839b2..d63d32694a 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDocService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDocService.java
@@ -78,4 +78,53 @@ public interface WxCpOaWeDocService {
* @throws WxErrorException the wx error exception
*/
WxCpDocShare docShare(@NonNull String docId) throws WxErrorException;
+
+ /**
+ * 编辑表格内容
+ * 该接口可以对一个在线表格批量执行多个更新操作
+ *
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/living/get_living_info?access_token=ACCESS_TOKEN&livingid
- * =LIVINGID
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/living/get_living_info?access_token=ACCESS_TOKEN&livingid=LIVINGID}
+ *
*
* @param livingId the living id
* @return living info
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolUserService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolUserService.java
index a92bfcc100..d004ca8aa5 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolUserService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolUserService.java
@@ -19,9 +19,10 @@ public interface WxCpSchoolUserService {
/**
* 获取访问用户身份
* 该接口用于根据code获取成员信息
- *
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=ACCESS_TOKEN&code=CODE
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=ACCESS_TOKEN&code=CODE}
+ *
*
* @param code the code
* @return user info
@@ -32,9 +33,10 @@ public interface WxCpSchoolUserService {
/**
* 获取家校访问用户身份
* 该接口用于根据code获取家长或者学生信息
- *
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/getuserinfo?access_token=ACCESS_TOKEN&code=CODE
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/getuserinfo?access_token=ACCESS_TOKEN&code=CODE}
+ *
*
* @param code the code
* @return school user info
@@ -90,8 +92,10 @@ public interface WxCpSchoolUserService {
/**
* 删除学生
+ *
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/delete_student?access_token=ACCESS_TOKEN&userid=USERID
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/delete_student?access_token=ACCESS_TOKEN&userid=USERID}
+ *
*
* @param studentUserId the student user id
* @return wx cp base resp
@@ -160,8 +164,10 @@ WxCpBaseResp updateStudent(@NonNull String studentUserId, String newStudentUserI
/**
* 读取学生或家长
+ *
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/get?access_token=ACCESS_TOKEN&userid=USERID
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/get?access_token=ACCESS_TOKEN&userid=USERID}
+ *
*
* @param userId the user id
* @return user
@@ -171,9 +177,10 @@ WxCpBaseResp updateStudent(@NonNull String studentUserId, String newStudentUserI
/**
* 获取部门成员详情
+ *
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/list?access_token=ACCESS_TOKEN&department_id=DEPARTMENT_ID
- * &fetch_child=FETCH_CHILD
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/list?access_token=ACCESS_TOKEN&department_id=DEPARTMENT_ID&fetch_child=FETCH_CHILD}
+ *
*
* @param departmentId 获取的部门id
* @param fetchChild 1/0:是否递归获取子部门下面的成员
@@ -184,9 +191,10 @@ WxCpBaseResp updateStudent(@NonNull String studentUserId, String newStudentUserI
/**
* 获取部门家长详情
+ *
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/list_parent?access_token=ACCESS_TOKEN&department_id
- * =DEPARTMENT_ID
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/list_parent?access_token=ACCESS_TOKEN&department_id=DEPARTMENT_ID}
+ *
*
* @param departmentId 获取的部门id
* @return user list parent
@@ -207,8 +215,10 @@ WxCpBaseResp updateStudent(@NonNull String studentUserId, String newStudentUserI
/**
* 删除家长
+ *
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/delete_parent?access_token=ACCESS_TOKEN&userid=USERID
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/delete_parent?access_token=ACCESS_TOKEN&userid=USERID}
+ *
*
* @param userId the user id
* @return wx cp base resp
@@ -256,7 +266,7 @@ WxCpBaseResp updateStudent(@NonNull String studentUserId, String newStudentUserI
/**
* 删除部门
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/department/delete?access_token=ACCESS_TOKEN&id=ID
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/department/delete?access_token=ACCESS_TOKEN&id=ID}
*
* @param id the id
* @return wx cp base resp
@@ -292,10 +302,9 @@ WxCpBaseResp updateStudent(@NonNull String studentUserId, String newStudentUserI
/**
* 获取外部联系人详情
* 学校可通过此接口,根据外部联系人的userid(如何获取?),拉取外部联系人详情。
- *
* 获取部门成员详情
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=ACCESS_TOKEN&department_id=DEPARTMENT_ID&fetch_child=FETCH_CHILD
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=ACCESS_TOKEN&department_id=DEPARTMENT_ID&fetch_child=FETCH_CHILD}
*
* 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/90201
*
@@ -213,7 +213,7 @@ public interface WxCpUserService {
* 获取加入企业二维码。
*
* 请求方式:GET(HTTPS)
- * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/corp/get_join_qrcode?access_token=ACCESS_TOKEN&size_type=SIZE_TYPE
+ * {@code 请求地址:https://qyapi.weixin.qq.com/cgi-bin/corp/get_join_qrcode?access_token=ACCESS_TOKEN&size_type=SIZE_TYPE}
*
* 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/91714
*
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImpl.java
index 81628fed82..cc08d33bb1 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImpl.java
@@ -11,6 +11,7 @@
import me.chanjar.weixin.cp.api.WxCpAgentService;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpAgent;
+import me.chanjar.weixin.cp.bean.WxCpTpAdmin;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import java.util.List;
@@ -65,4 +66,21 @@ public List
+ *
*
*
+ *
*
*
* 请使用.
- * {@link LinkedCorpMsgType#TEXT}
- * {@link LinkedCorpMsgType#IMAGE}
- * {@link LinkedCorpMsgType#VIDEO}
- * {@link LinkedCorpMsgType#NEWS}
- * {@link LinkedCorpMsgType#MPNEWS}
- * {@link LinkedCorpMsgType#MARKDOWN}
- * {@link LinkedCorpMsgType#MINIPROGRAM_NOTICE}
+ * {@link me.chanjar.weixin.cp.constant.WxCpConsts.LinkedCorpMsgType#TEXT}
+ * {@link me.chanjar.weixin.cp.constant.WxCpConsts.LinkedCorpMsgType#IMAGE}
+ * {@link me.chanjar.weixin.cp.constant.WxCpConsts.LinkedCorpMsgType#VIDEO}
+ * {@link me.chanjar.weixin.cp.constant.WxCpConsts.LinkedCorpMsgType#NEWS}
+ * {@link me.chanjar.weixin.cp.constant.WxCpConsts.LinkedCorpMsgType#MPNEWS}
+ * {@link me.chanjar.weixin.cp.constant.WxCpConsts.LinkedCorpMsgType#MARKDOWN}
+ * {@link me.chanjar.weixin.cp.constant.WxCpConsts.LinkedCorpMsgType#MINIPROGRAM_NOTICE}
*
*
* @param msgType 消息类型
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessage.java
index c5e55220e5..08a0936317 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessage.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessage.java
@@ -68,19 +68,19 @@ public class WxCpXmlMessage implements Serializable {
/**
*
* 当接受用户消息时,可能会获得以下值:
- * {@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}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#TEXT}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#IMAGE}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#VOICE}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#VIDEO}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#LOCATION}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#LINK}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#EVENT}
* 当发送消息的时候使用:
- * {@link WxConsts.XmlMsgType#TEXT}
- * {@link WxConsts.XmlMsgType#IMAGE}
- * {@link WxConsts.XmlMsgType#VOICE}
- * {@link WxConsts.XmlMsgType#VIDEO}
- * {@link WxConsts.XmlMsgType#NEWS}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#TEXT}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#IMAGE}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#VOICE}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#VIDEO}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#NEWS}
*
*/
@XStreamAlias("MsgType")
@@ -157,7 +157,7 @@ public class WxCpXmlMessage implements Serializable {
@XStreamAlias("MemChangeList")
@XStreamConverter(value = XStreamCDataConverter.class)
- private String MemChangeList;
+ private String memChangeList;
@XStreamAlias("LastMemVer")
@XStreamConverter(value = XStreamCDataConverter.class)
@@ -253,6 +253,24 @@ public class WxCpXmlMessage implements Serializable {
@XStreamConverter(value = XStreamCDataConverter.class)
private String linkId;
+ /**
+ * 智能机器人ID
+ * 接收智能机器人消息时使用
+ * https://developer.work.weixin.qq.com/document/path/100719
+ */
+ @XStreamAlias("RobotId")
+ @XStreamConverter(value = XStreamCDataConverter.class)
+ private String robotId;
+
+ /**
+ * 智能机器人会话ID
+ * 接收智能机器人消息时使用,用于保持会话连续性
+ * https://developer.work.weixin.qq.com/document/path/100719
+ */
+ @XStreamAlias("SessionId")
+ @XStreamConverter(value = XStreamCDataConverter.class)
+ private String sessionId;
+
/**
* 通讯录变更事件.
* 请参考常量 me.chanjar.weixin.cp.constant.WxCpConsts.ContactChangeType
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TemplateCardBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TemplateCardBuilder.java
index d3cbb89a3d..1ab92630a9 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TemplateCardBuilder.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TemplateCardBuilder.java
@@ -12,7 +12,8 @@
* 用法: WxCustomMessage m = WxCustomMessage.TEMPLATECARD().title(...)....toUser(...).build();
*
*
- * @author yzts a> created on 2019-05-16
+ * @author yzts
+ * @since 2019-05-16
*/
public class TemplateCardBuilder extends BaseBuilder
+ *
* 取值范围:-604800 ~ 86399
*/
@SerializedName("remind_time_diffs")
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/doc/WxCpDocSheetBatchUpdateRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/doc/WxCpDocSheetBatchUpdateRequest.java
new file mode 100644
index 0000000000..37c42717e7
--- /dev/null
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/doc/WxCpDocSheetBatchUpdateRequest.java
@@ -0,0 +1,199 @@
+package me.chanjar.weixin.cp.bean.oa.doc;
+
+import java.io.Serializable;
+import java.util.List;
+
+import com.google.gson.annotations.SerializedName;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+import me.chanjar.weixin.cp.bean.oa.doc.WxCpDocSheetData.GridData;
+import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
+
+/**
+ * 编辑表格内容请求
+ *
+ * @author zhongying
+ * @since 2026-01-07
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@Accessors(chain = true)
+public class WxCpDocSheetBatchUpdateRequest implements Serializable {
+ private static final long serialVersionUID = 584565591133421347L;
+
+ /**
+ * 文档的docid.必填
+ */
+ @SerializedName("docid")
+ private String docId;
+
+ /**
+ * 更新操作列表.必填
+ */
+ @SerializedName("requests")
+ private List
+ *
* 会议室冲突日期列表,为当天0点的时间戳;使用重复会议预定会议室,部分日期与会议室预定情况冲突时返回
*/
@SerializedName("conflict_date")
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTips.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTips.java
index 58daeb007c..eada2ad100 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTips.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTips.java
@@ -8,7 +8,7 @@
/**
* @author mrsiu@msn.com
* @version 1.0
- * @date 2025/1/16 09:40
+ * @since 2025/1/16 09:40
*/
@Data
public class TemplateTips {
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsContent.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsContent.java
index 939e6819a0..0af8be8be5 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsContent.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsContent.java
@@ -5,7 +5,7 @@
/**
* @author mrsiu@msn.com
* @version 1.0
- * @date 2025/1/16 09:42
+ * @since 2025/1/16 09:42
*/
@Data
public class TemplateTipsContent {
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsSubText.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsSubText.java
index ac4681038c..78e88562e8 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsSubText.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsSubText.java
@@ -5,7 +5,7 @@
/**
* @author mrsiu@msn.com
* @version 1.0
- * @date 2025/1/16 09:45
+ * @since 2025/1/16 09:45
*/
@Data
public class TemplateTipsSubText {
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsSubTextContent.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsSubTextContent.java
index 9c99b2688e..f33c31d054 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsSubTextContent.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsSubTextContent.java
@@ -6,7 +6,7 @@
/**
* @author mrsiu@msn.com
* @version 1.0
- * @date 2025/1/16 09:46
+ * @since 2025/1/16 09:46
*/
@Data
public class TemplateTipsSubTextContent {
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsSubTextContentLink.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsSubTextContentLink.java
index 4cd198409a..fd4db2c18f 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsSubTextContentLink.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsSubTextContentLink.java
@@ -5,7 +5,7 @@
/**
* @author mrsiu@msn.com
* @version 1.0
- * @date 2025/1/16 09:49
+ * @since 2025/1/16 09:49
*/
@Data
public class TemplateTipsSubTextContentLink {
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsSubTextContentPlainText.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsSubTextContentPlainText.java
index 12969cdcdb..0a2e792edb 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsSubTextContentPlainText.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsSubTextContentPlainText.java
@@ -3,9 +3,9 @@
import lombok.Data;
/**
- * @author mrsiu@msn.com
- * @date 2025/1/16 09:47
- * @version 1.0
+ * @author mrsiu@msn.com
+ * @version 1.0
+ * @since 2025/1/16 09:47
*/
@Data
public class TemplateTipsSubTextContentPlainText {
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsText.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsText.java
index 100c5bb137..c9dbe68abf 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsText.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/templatedata/TemplateTipsText.java
@@ -6,9 +6,9 @@
import java.util.List;
/**
- * @author mrsiu@msn.com
- * @date 2025/1/16 09:43
- * @version 1.0
+ * @author mrsiu@msn.com
+ * @version 1.0
+ * @since 2025/1/16 09:43
*/
@Data
public class TemplateTipsText {
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpCorpGroupConfigStorage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpCorpGroupConfigStorage.java
index 07acb189a8..df758ac3a2 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpCorpGroupConfigStorage.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpCorpGroupConfigStorage.java
@@ -31,8 +31,8 @@ public interface WxCpCorpGroupConfigStorage {
/**
* Update corp access token.
*
- * @param corpId
- * @param agentId
+ * @param corpId 企业ID
+ * @param agentId 应用ID
* @param corpAccessToken the corp access token
* @param expiresInSeconds the expires in seconds
*/
@@ -41,8 +41,8 @@ public interface WxCpCorpGroupConfigStorage {
/**
* 授权企业的access token相关
*
- * @param corpId the corp id
- * @param agentId
+ * @param corpId 企业ID
+ * @param agentId 应用ID
* @return the access token
*/
String getCorpAccessToken(String corpId, Integer agentId);
@@ -50,8 +50,8 @@ public interface WxCpCorpGroupConfigStorage {
/**
* Gets access token entity.
*
- * @param corpId the corp id
- * @param agentId
+ * @param corpId 企业ID
+ * @param agentId 应用ID
* @return the access token entity
*/
WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId);
@@ -59,8 +59,8 @@ public interface WxCpCorpGroupConfigStorage {
/**
* Is access token expired boolean.
*
- * @param corpId the corp id
- * @param agentId
+ * @param corpId 企业ID
+ * @param agentId 应用ID
* @return the boolean
*/
boolean isCorpAccessTokenExpired(String corpId, Integer agentId);
@@ -68,8 +68,8 @@ public interface WxCpCorpGroupConfigStorage {
/**
* Expire access token.
*
- * @param corpId the corp id
- * @param agentId
+ * @param corpId 企业ID
+ * @param agentId 应用ID
*/
void expireCorpAccessToken(String corpId, Integer agentId);
@@ -118,7 +118,8 @@ public interface WxCpCorpGroupConfigStorage {
/**
* Gets access token lock.
*
- * @param corpId the corp id
+ * @param corpId 企业ID
+ * @param agentId 应用ID
* @return the access token lock
*/
Lock getCorpAccessTokenLock(String corpId, Integer agentId);
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpTpConfigStorage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpTpConfigStorage.java
index 2cd37821b5..0a2ed0e76a 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpTpConfigStorage.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpTpConfigStorage.java
@@ -133,7 +133,7 @@ public interface WxCpTpConfigStorage {
String getEncodingAESKey();
/**
- * 企微服务商企业ID & 企业secret
+ * {@code 企微服务商企业ID & 企业secret}
*
* @return the corp id
*/
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/AbstractWxCpTpInRedisConfigImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/AbstractWxCpTpInRedisConfigImpl.java
index 08eed33c16..6d1260fe68 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/AbstractWxCpTpInRedisConfigImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/AbstractWxCpTpInRedisConfigImpl.java
@@ -187,7 +187,9 @@ public String getEncodingAESKey() {
/**
- * 企微服务商企业ID & 企业secret, 来自于企微配置
+ * {@code 企微服务商企业ID & 企业secret, 来自于企微配置}
+ *
+ * @return 企业ID
*/
@Override
public String getCorpId() {
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpRedisConfigImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpRedisConfigImpl.java
index 15c0ff6727..49cd7c4559 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpRedisConfigImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpRedisConfigImpl.java
@@ -468,7 +468,7 @@ public boolean autoRefreshToken() {
@Override
public String getWebhookKey() {
- return this.getWebhookKey();
+ return this.webhookKey;
}
@Override
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpTpDefaultConfigImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpTpDefaultConfigImpl.java
index fc124251f5..7fbbc9ccce 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpTpDefaultConfigImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpTpDefaultConfigImpl.java
@@ -29,7 +29,7 @@ public class WxCpTpDefaultConfigImpl implements WxCpTpConfigStorage, Serializabl
private final transient Map
- * 获取审批申请详情
+ * 获取审批申请详情
*
* @param spNo 审批单编号。
* @param corpId the corp id
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOrderService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOrderService.java
index 3aff90bb56..6e0acb7dee 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOrderService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpOrderService.java
@@ -18,7 +18,7 @@ public interface WxCpTpOrderService {
* 获取订单详情
*
* 文档地址
- *
+ *
*
* @param orderId 订单号
* @return the order
@@ -31,7 +31,7 @@ public interface WxCpTpOrderService {
* 获取订单列表
*
* 文档地址
- *
+ *
*
* @param startTime 起始时间
* @param endTime 终止时间
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpService.java
index b24be535da..93855d1a48 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpService.java
@@ -199,7 +199,7 @@ public interface WxCpTpService {
* @return permanent code info
* @throws WxErrorException the wx error exception
* @author yuan
- * @since 2020 -03-18
+ * @since 2020-03-18
*/
WxCpTpPermanentCodeInfo getPermanentCodeInfo(String authCode) throws WxErrorException;
@@ -227,7 +227,7 @@ public interface WxCpTpService {
* @param authType 授权类型:0 正式授权, 1 测试授权。
* @return pre auth url
* @throws WxErrorException the wx error exception
- * @link https ://work.weixin.qq.com/api/doc/90001/90143/90602
+ * @see 文档地址
*/
String getPreAuthUrl(String redirectUri, String state, int authType) throws WxErrorException;
@@ -558,12 +558,12 @@ WxCpTpXmlMessage fromEncryptedXml(String encryptedXml,
WxCpTpAppQrcode getAppQrcode(String suiteId, String appId, String state, Integer style, Integer resultType) throws WxErrorException ;
/**
- *
* 明文corpid转换为加密corpid 为更好地保护企业与用户的数据,第三方应用获取的corpid不再是明文的corpid,将升级为第三方服务商级别的加密corpid。文档说明
* 第三方可以将已有的明文corpid转换为第三方的加密corpid。
- * @param corpId
- * @return
- * @throws WxErrorException
+ *
+ * @param corpId 企业ID
+ * @return 加密的企业ID
+ * @throws WxErrorException 微信错误异常
*/
WxCpTpCorpId2OpenCorpId corpId2OpenCorpId(String corpId) throws WxErrorException;
@@ -655,6 +655,8 @@ WxCpTpXmlMessage fromEncryptedXml(String encryptedXml,
/**
* 构造第三方应用oauth2链接
+ *
+ * @return OAuth2服务
*/
WxCpTpOAuth2Service getWxCpTpOAuth2Service();
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpTagService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpTagService.java
index b508df59a1..df60041865 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpTagService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpTagService.java
@@ -13,7 +13,7 @@
*
*
* @author zhangq * 文档地址 - *
+ * ** 文档地址 - *
+ * * * @param orderId 订单号 * @return the order @@ -49,7 +49,7 @@ public WxCpTpOrderDetails getOrder(String orderId) throws WxErrorException { * 获取订单列表 ** 文档地址 - *
+ * * * @param startTime 起始时间 * @param endTime 终止时间 diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceHttpComponentsImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceHttpComponentsImpl.java index bba597a3ee..44b5fd8693 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceHttpComponentsImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceHttpComponentsImpl.java @@ -10,7 +10,6 @@ import me.chanjar.weixin.common.util.http.hc.DefaultHttpComponentsClientBuilder; import me.chanjar.weixin.common.util.http.hc.HttpComponentsClientBuilder; import me.chanjar.weixin.common.util.json.GsonParser; -import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; import org.apache.hc.client5.http.classic.methods.HttpPost; import org.apache.hc.client5.http.config.RequestConfig; @@ -87,9 +86,10 @@ public void initHttp() { HttpComponentsClientBuilder apacheHttpClientBuilder = DefaultHttpComponentsClientBuilder.get(); apacheHttpClientBuilder.httpProxyHost(this.configStorage.getHttpProxyHost()) - .httpProxyPort(this.configStorage.getHttpProxyPort()) - .httpProxyUsername(this.configStorage.getHttpProxyUsername()) - .httpProxyPassword(this.configStorage.getHttpProxyPassword().toCharArray()); + .httpProxyPort(this.configStorage.getHttpProxyPort()) + .httpProxyUsername(this.configStorage.getHttpProxyUsername()) + .httpProxyPassword(this.configStorage.getHttpProxyPassword() == null ? null : + this.configStorage.getHttpProxyPassword().toCharArray()); if (this.configStorage.getHttpProxyHost() != null && this.configStorage.getHttpProxyPort() > 0) { this.httpProxy = new HttpHost(this.configStorage.getHttpProxyHost(), this.configStorage.getHttpProxyPort()); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpTagServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpTagServiceImpl.java index b81760e72c..1b03f18c79 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpTagServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpTagServiceImpl.java @@ -25,7 +25,7 @@ * * * @author zhangq+ * 创建设备组 + * 详情请见:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/hardware-device/createIotGroupId.html + *+ * + * @param createIotGroupIdRequest 请求参数 + * @return 设备组的唯一标识 + * @throws WxErrorException + */ + String createIotGroupId(WxMaCreateIotGroupIdRequest createIotGroupIdRequest) throws WxErrorException; + + /** + *
+ * 查询设备组信息 + * 详情请见:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/hardware-device/getIotGroupInfo.html + *+ * + * @param getIotGroupInfoRequest 请求参数 + * @return 设备组信息 + * @throws WxErrorException + */ + WxMaIotGroupDeviceInfoResponse getIotGroupInfo(WxMaGetIotGroupInfoRequest getIotGroupInfoRequest) throws WxErrorException; + + /** + *
+ * 设备组添加设备 + * 一个设备组最多添加 50 个设备。 一个设备同一时间只能被添加到一个设备组中。 + * 详情请见:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/hardware-device/addIotGroupDevice.html + *+ * + * @param request 请求参数 + * @return 成功添加的设备信息 + * @throws WxErrorException + */ + List
+ * 设备组删除设备 + * 详情请见:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/hardware-device/removeIotGroupDevice.html + *+ * + * @param request 请求参数 + * @return 成功删除的设备信息 + * @throws WxErrorException + */ + List
+ * 文档地址:用工关系简介 + *
+ * + * @author Binary Wang + * created on 2025-12-19 + */ +public interface WxMaEmployeeRelationService { + + /** + * 解绑用工关系 + *+ * 企业可以调用该接口解除和用户的B2C用工关系 + *
+ * 文档地址:解绑用工关系 + * + * @param request 解绑请求参数 + * @throws WxErrorException 调用微信接口失败时抛出 + */ + void unbindEmployee(WxMaUnbindEmployeeRequest request) throws WxErrorException; + + /** + * 推送用工消息 + *+ * 企业可以调用该接口向用户推送用工相关消息 + *
+ * 文档地址:推送用工消息 + * + * @param request 推送消息请求参数 + * @throws WxErrorException 调用微信接口失败时抛出 + */ + void sendEmployeeMsg(WxMaSendEmployeeMsgRequest request) throws WxErrorException; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java index 26ced8bedd..dc7425fa6e 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java @@ -621,4 +621,13 @@ WxMaApiResponse execute( * @return 交易投诉服务对象WxMaComplaintService */ WxMaComplaintService getComplaintService(); + + /** + * 获取用工关系服务对象。 + *+ * 文档地址:推送用工消息 + *
+ * + * @author Binary Wang + * created on 2025-12-19 + */ +@Data +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +public class WxMaSendEmployeeMsgRequest implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *+ * 字段名:用户openid + * 是否必填:是 + * 描述:需要接收消息的用户openid + *+ */ + @SerializedName("openid") + private String openid; + + /** + *
+ * 字段名:企业id + * 是否必填:是 + * 描述:企业id,小程序管理员在微信开放平台配置 + *+ */ + @SerializedName("corp_id") + private String corpId; + + /** + *
+ * 字段名:消息内容 + * 是否必填:是 + * 描述:推送的消息内容,文本格式,最长不超过200个字符 + *+ */ + @SerializedName("msg") + private String msg; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/employee/WxMaUnbindEmployeeRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/employee/WxMaUnbindEmployeeRequest.java new file mode 100644 index 0000000000..e56d84670c --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/employee/WxMaUnbindEmployeeRequest.java @@ -0,0 +1,51 @@ +package cn.binarywang.wx.miniapp.bean.employee; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 小程序解绑用工关系请求实体 + *
+ * 文档地址:解绑用工关系 + *
+ * + * @author Binary Wang + * created on 2025-12-19 + */ +@Data +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +public class WxMaUnbindEmployeeRequest implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *+ * 字段名:用户openid + * 是否必填:是 + * 描述:需要解绑的用户openid + *+ */ + @SerializedName("openid") + private String openid; + + /** + *
+ * 字段名:企业id + * 是否必填:是 + * 描述:企业id,小程序管理员在微信开放平台配置 + *+ */ + @SerializedName("corp_id") + private String corpId; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressOrderCargo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressOrderCargo.java index 96817a2256..b6de21b9e6 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressOrderCargo.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/express/request/WxMaExpressOrderCargo.java @@ -34,7 +34,7 @@ public class WxMaExpressOrderCargo implements Serializable { * 描述: 单位是千克(kg) * */ - private Integer weight; + private Double weight; /** * 包裹长度 @@ -44,7 +44,7 @@ public class WxMaExpressOrderCargo implements Serializable { * */ @SerializedName("space_x") - private Integer spaceLength; + private Double spaceLength; /** * 包裹宽度 @@ -54,7 +54,7 @@ public class WxMaExpressOrderCargo implements Serializable { * */ @SerializedName("space_y") - private Integer spaceWidth; + private Double spaceWidth; /** * 包裹高度 @@ -64,7 +64,7 @@ public class WxMaExpressOrderCargo implements Serializable { * */ @SerializedName("space_z") - private Integer spaceHeight; + private Double spaceHeight; /** * 包裹中商品详情列表 diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayPresentGoodsRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayPresentGoodsRequest.java new file mode 100644 index 0000000000..ba9d7100da --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayPresentGoodsRequest.java @@ -0,0 +1,63 @@ +package cn.binarywang.wx.miniapp.bean.xpay; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 小游戏道具直购API请求. + * + * @author Binary Wang + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayPresentGoodsRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312109L; + + /** + * 用户的openid. + */ + @SerializedName("openid") + private String openid; + + /** + * 环境。0-正式环境;1-沙箱环境. + */ + @SerializedName("env") + private Integer env; + + /** + * 商户订单号. + */ + @SerializedName("order_id") + private String orderId; + + /** + * 设备类型。0-安卓;1-iOS. + */ + @SerializedName("device_type") + private Integer deviceType; + + /** + * 道具id. + */ + @SerializedName("goods_id") + private String goodsId; + + /** + * 道具数量. + */ + @SerializedName("goods_number") + private Integer goodsNumber; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayPresentGoodsResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayPresentGoodsResponse.java new file mode 100644 index 0000000000..ed3ea8d7f0 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayPresentGoodsResponse.java @@ -0,0 +1,34 @@ +package cn.binarywang.wx.miniapp.bean.xpay; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 小游戏道具直购API响应. + * + * @author Binary Wang + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaXPayPresentGoodsResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312110L; + + /** + * 商户订单号. + */ + @SerializedName("order_id") + private String orderId; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} 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 c353534c3f..71f49ee2d3 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 @@ -8,6 +8,7 @@ public class BaseBuilder
* 创建卡券
- *
*
- * @param cardCreateRequest 卡券创建请求对象
+ * @param cardCreateMessage 卡券创建请求对象
* @return 卡券创建结果对象
* @throws WxErrorException 微信API调用异常,可能包括:
*
* 获取图文群发总数据(getarticletotal)
- * 详情请见文档:图文分析数据接口
+ *
+ * {@code 详情请见文档:图文分析数据接口}
+ *
+ *
* 接口url格式:https://api.weixin.qq.com/datacube/getarticletotal?access_token=ACCESS_TOKEN
+ *
*
* @param beginDate 开始时间
* @param endDate 最大时间跨度1天,endDate不能早于begingDate
@@ -73,10 +76,13 @@ public interface WxMpDataCubeService {
List getArticleTotal(Date beginDate, Date endDate) throws WxErrorException;
/**
- *
* 获取图文统计数据(getuserread)
- * 详情请见文档:图文分析数据接口
+ *
+ * {@code 详情请见文档:图文分析数据接口}
+ *
+ *
* 接口url格式:https://api.weixin.qq.com/datacube/getuserread?access_token=ACCESS_TOKEN
+ *
*
* @param beginDate 开始时间
* @param endDate 最大时间跨度3天,endDate不能早于begingDate
@@ -86,10 +92,13 @@ public interface WxMpDataCubeService {
List getUserRead(Date beginDate, Date endDate) throws WxErrorException;
/**
- *
* 获取图文统计分时数据(getuserreadhour)
- * 详情请见文档:图文分析数据接口
+ *
+ * {@code 详情请见文档:图文分析数据接口}
+ *
+ *
* 接口url格式:https://api.weixin.qq.com/datacube/getuserreadhour?access_token=ACCESS_TOKEN
+ *
*
* @param beginDate 开始时间
* @param endDate 最大时间跨度1天,endDate不能早于begingDate
@@ -99,10 +108,13 @@ public interface WxMpDataCubeService {
List getUserReadHour(Date beginDate, Date endDate) throws WxErrorException;
/**
- *
* 获取图文分享转发数据(getusershare)
- * 详情请见文档:图文分析数据接口
+ *
+ * {@code 详情请见文档:图文分析数据接口}
+ *
+ *
* 接口url格式:https://api.weixin.qq.com/datacube/getusershare?access_token=ACCESS_TOKEN
+ *
*
* @param beginDate 开始时间
* @param endDate 最大时间跨度7天,endDate不能早于begingDate
@@ -112,10 +124,13 @@ public interface WxMpDataCubeService {
List getUserShare(Date beginDate, Date endDate) throws WxErrorException;
/**
- *
* 获取图文分享转发分时数据(getusersharehour)
- * 详情请见文档:图文分析数据接口
+ *
+ * {@code 详情请见文档:图文分析数据接口}
+ *
+ *
* 接口url格式:https://api.weixin.qq.com/datacube/getusersharehour?access_token=ACCESS_TOKEN
+ *
*
* @param beginDate 开始时间
* @param endDate 最大时间跨度1天,endDate不能早于begingDate
@@ -127,10 +142,13 @@ public interface WxMpDataCubeService {
//*******************消息分析数据接口***********************//
/**
- *
* 获取消息发送概况数据(getupstreammsg)
- * 详情请见文档:消息分析数据接口
+ *
+ * {@code 详情请见文档:消息分析数据接口}
+ *
+ *
* 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsg?access_token=ACCESS_TOKEN
+ *
*
* @param beginDate 开始时间
* @param endDate 最大时间跨度7天,endDate不能早于begingDate
@@ -140,10 +158,13 @@ public interface WxMpDataCubeService {
List getUpstreamMsg(Date beginDate, Date endDate) throws WxErrorException;
/**
- *
* 获取消息分送分时数据(getupstreammsghour)
- * 详情请见文档:消息分析数据接口
+ *
+ * {@code 详情请见文档:消息分析数据接口}
+ *
+ *
* 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsghour?access_token=ACCESS_TOKEN
+ *
*
* @param beginDate 开始时间
* @param endDate 最大时间跨度1天,endDate不能早于begingDate
@@ -153,10 +174,13 @@ public interface WxMpDataCubeService {
List getUpstreamMsgHour(Date beginDate, Date endDate) throws WxErrorException;
/**
- *
* 获取消息发送周数据(getupstreammsgweek)
- * 详情请见文档:消息分析数据接口
+ *
+ * {@code 详情请见文档:消息分析数据接口}
+ *
+ *
* 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsgweek?access_token=ACCESS_TOKEN
+ *
*
* @param beginDate 开始时间
* @param endDate 最大时间跨度30天,endDate不能早于begingDate
@@ -166,10 +190,13 @@ public interface WxMpDataCubeService {
List getUpstreamMsgWeek(Date beginDate, Date endDate) throws WxErrorException;
/**
- *
* 获取消息发送月数据(getupstreammsgmonth)
- * 详情请见文档:消息分析数据接口
+ *
+ * {@code 详情请见文档:消息分析数据接口}
+ *
+ *
* 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsgmonth?access_token=ACCESS_TOKEN
+ *
*
* @param beginDate 开始时间
* @param endDate 最大时间跨度30天,endDate不能早于begingDate
@@ -179,10 +206,13 @@ public interface WxMpDataCubeService {
List getUpstreamMsgMonth(Date beginDate, Date endDate) throws WxErrorException;
/**
- *
* 获取消息发送分布数据(getupstreammsgdist)
- * 详情请见文档:消息分析数据接口
+ *
+ * {@code 详情请见文档:消息分析数据接口}
+ *
+ *
* 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsgdist?access_token=ACCESS_TOKEN
+ *
*
* @param beginDate 开始时间
* @param endDate 最大时间跨度15天,endDate不能早于begingDate
@@ -192,10 +222,13 @@ public interface WxMpDataCubeService {
List getUpstreamMsgDist(Date beginDate, Date endDate) throws WxErrorException;
/**
- *
* 获取消息发送分布周数据(getupstreammsgdistweek)
- * 详情请见文档:消息分析数据接口
+ *
+ * {@code 详情请见文档:消息分析数据接口}
+ *
+ *
* 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsgdistweek?access_token=ACCESS_TOKEN
+ *
*
* @param beginDate 开始时间
* @param endDate 最大时间跨度30天,endDate不能早于begingDate
@@ -205,10 +238,13 @@ public interface WxMpDataCubeService {
List getUpstreamMsgDistWeek(Date beginDate, Date endDate) throws WxErrorException;
/**
- *
* 获取消息发送分布月数据(getupstreammsgdistmonth)
- * 详情请见文档:消息分析数据接口
+ *
+ * {@code 详情请见文档:消息分析数据接口}
+ *
+ *
* 接口url格式:https://api.weixin.qq.com/datacube/getupstreammsgdistmonth?access_token=ACCESS_TOKEN
+ *
*
* @param beginDate 开始时间
* @param endDate 最大时间跨度30天,endDate不能早于begingDate
@@ -220,10 +256,13 @@ public interface WxMpDataCubeService {
//*******************接口分析数据接口***********************//
/**
- *
* 获取接口分析数据(getinterfacesummary)
- * 详情请见文档:接口分析数据接口
+ *
+ * {@code 详情请见文档:接口分析数据接口}
+ *
+ *
* 接口url格式:https://api.weixin.qq.com/datacube/getinterfacesummary?access_token=ACCESS_TOKEN
+ *
*
* @param beginDate 开始时间
* @param endDate 最大时间跨度30天,endDate不能早于begingDate
@@ -233,10 +272,13 @@ public interface WxMpDataCubeService {
List getInterfaceSummary(Date beginDate, Date endDate) throws WxErrorException;
/**
- *
* 获取接口分析分时数据(getinterfacesummaryhour)
- * 详情请见文档:接口分析数据接口
+ *
+ * {@code 详情请见文档:接口分析数据接口}
+ *
+ *
* 接口url格式:https://api.weixin.qq.com/datacube/getinterfacesummaryhour?access_token=ACCESS_TOKEN
+ *
*
* @param beginDate 开始时间
* @param endDate 最大时间跨度1天,endDate不能早于begingDate
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 468dced138..2d965bf8de 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
@@ -54,10 +54,10 @@ public interface WxMpService extends WxService {
WxMpShortKeyResult fetchShorten(String shortKey) throws WxErrorException;
/**
- *
* 验证消息的确来自微信服务器.
- * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421135319&token=&lang=zh_CN
- *
+ *
+ * {@code 详情请见: 接入指南}
+ *
*
* @param timestamp 时间戳,字符串格式
* @param nonce 随机串,字符串格式
@@ -76,16 +76,19 @@ public interface WxMpService extends WxService {
String getAccessToken() throws WxErrorException;
/**
- *
* 获取access_token,本方法线程安全.
+ *
* 且在多线程同时刷新时只刷新一次,避免超出2000次/日的调用次数上限
- *
+ *
+ *
* 另:本service的所有方法都会在access_token过期时调用此方法
- *
+ *
+ *
* 程序员在非必要情况下尽量不要主动调用此方法
- *
- * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140183&token=&lang=zh_CN
- *
+ *
+ *
+ * {@code 详情请见: 获取access_token}
+ *
*
* @param forceRefresh 是否强制刷新,true表示强制刷新,false表示使用缓存
* @return token access token,字符串格式
@@ -126,12 +129,13 @@ public interface WxMpService extends WxService {
String getJsapiTicket() throws WxErrorException;
/**
- *
* 获得jsapi_ticket.
+ *
* 获得时会检查jsapiToken是否过期,如果过期了,那么就刷新一下,否则就什么都不干
- *
- * 详情请见:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN
- *
+ *
+ *
+ * {@code 详情请见:JS-SDK使用权限签名算法}
+ *
*
* @param forceRefresh 强制刷新,true表示强制刷新,false表示使用缓存
* @return jsapi ticket,字符串格式
@@ -140,11 +144,10 @@ public interface WxMpService extends WxService {
String getJsapiTicket(boolean forceRefresh) throws WxErrorException;
/**
- *
* 创建调用jsapi时所需要的签名.
- *
- * 详情请见:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN
- *
+ *
+ * {@code 详情请见:JS-SDK使用权限签名算法}
+ *
*
* @param url 当前网页的URL,不包括#及其后面部分
* @return 生成的签名对象,包含签名、时间戳、随机串等信息
@@ -153,10 +156,10 @@ public interface WxMpService extends WxService {
WxJsapiSignature createJsapiSignature(String url) throws WxErrorException;
/**
- *
* 长链接转短链接接口.
- * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=长链接转短链接接口
- *
+ *
+ * 详情请见: 长链接转短链接接口
+ *
*
* @param longUrl 长url,需要转换的原始URL
* @return 生成的短地址,字符串格式
@@ -167,10 +170,10 @@ public interface WxMpService extends WxService {
String shortUrl(String longUrl) throws WxErrorException;
/**
- *
* 语义查询接口.
- * 详情请见:http://mp.weixin.qq.com/wiki/index.php?title=语义理解
- *
+ *
+ * 详情请见:语义理解
+ *
*
* @param semanticQuery 查询条件,包含查询内容、类型等信息
* @return 查询结果,包含语义理解的结果和建议回复
@@ -179,11 +182,13 @@ public interface WxMpService extends WxService {
WxMpSemanticQueryResult semanticQuery(WxMpSemanticQuery semanticQuery) throws WxErrorException;
/**
- *
* 构造第三方使用网站应用授权登录的url.
- * 详情请见: 网站应用微信登录开发指南
- * URL格式为:https://open.weixin.qq.com/connect/qrconnect?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect
- *
+ *
+ * {@code 详情请见: 网站应用微信登录开发指南}
+ *
+ *
+ * {@code URL格式为:https://open.weixin.qq.com/connect/qrconnect?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect}
+ *
*
* @param redirectUri 用户授权完成后的重定向链接,无需urlencode, 方法内会进行encode
* @param scope 应用授权作用域,拥有多个作用域用逗号(,)分隔,网页应用目前仅填写snsapi_login即可
@@ -193,10 +198,7 @@ public interface WxMpService extends WxService {
String buildQrConnectUrl(String redirectUri, String scope, String state);
/**
- *
* 获取微信服务器IP地址
- * http://mp.weixin.qq.com/wiki/0/2ad4b6bfd29f30f71d39616c2a0fcedc.html
- *
*
* @return 微信服务器ip地址数组,包含所有微信服务器IP地址
* @throws WxErrorException 微信API调用异常
@@ -204,11 +206,10 @@ public interface WxMpService extends WxService {
String[] getCallbackIP() throws WxErrorException;
/**
- *
- * 网络检测
- * https://mp.weixin.qq.com/wiki?t=resource/res_main&id=21541575776DtsuT
- * 为了帮助开发者排查回调连接失败的问题,提供这个网络检测的API。它可以对开发者URL做域名解析,然后对所有IP进行一次ping操作,得到丢包率和耗时。
- *
+ * 网络检测
+ *
+ * 为了帮助开发者排查回调连接失败的问题,提供这个网络检测的API。它可以对开发者URL做域名解析,然后对所有IP进行一次ping操作,得到丢包率和耗时。
+ *
*
* @param action 执行的检测动作,可选值:all(全部检测)、dns(仅域名解析)、ping(仅网络连通性检测)
* @param operator 指定平台从某个运营商进行检测,可选值:CHINANET(中国电信)、UNICOM(中国联通)、CAP(中国联通)、CUCC(中国联通)
@@ -239,12 +240,13 @@ public interface WxMpService extends WxService {
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
- *
- *
+ * 公众号调用或第三方平台帮公众号调用对公众号的所有api调用(包括第三方帮其调用)次数进行清零.
+ *
+ * HTTP调用:https://api.weixin.qq.com/cgi-bin/clear_quota?access_token=ACCESS_TOKEN
+ *
+ *
+ * {@code 接口文档地址:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433744592}
+ *
*
* @param appid 公众号的APPID,需要清零调用的公众号的appid
* @throws WxErrorException 微信API调用异常
@@ -252,11 +254,9 @@ public interface WxMpService extends WxService {
void clearQuota(String appid) throws WxErrorException;
/**
- *
* Service没有实现某个API的时候,可以用这个,
* 比{@link #get}和{@link #post}方法更灵活,可以自己构造RequestExecutor用来处理不同的参数和不同的返回类型。
* 可以参考,{@link MediaUploadRequestExecutor}的实现方法
- *
*
* @param 返回值类型
* @param 参数类型
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java
index 63ca608eba..76ab466157 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java
@@ -304,8 +304,9 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
/**
* 通过网络请求获取稳定版接口调用凭据
*
- * @return .
- * @throws IOException .
+ * @param forceRefresh 是否强制刷新
+ * @return access_token字符串
+ * @throws IOException IO异常
*/
protected abstract String doGetStableAccessTokenRequest(boolean forceRefresh) throws IOException;
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceHttpComponentsImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceHttpComponentsImpl.java
index bbf065acfc..c54202ad2f 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceHttpComponentsImpl.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceHttpComponentsImpl.java
@@ -51,7 +51,8 @@ public void initHttp() {
apacheHttpClientBuilder.httpProxyHost(configStorage.getHttpProxyHost())
.httpProxyPort(configStorage.getHttpProxyPort())
.httpProxyUsername(configStorage.getHttpProxyUsername())
- .httpProxyPassword(configStorage.getHttpProxyPassword().toCharArray());
+ .httpProxyPassword(configStorage.getHttpProxyPassword() == null ? null :
+ configStorage.getHttpProxyPassword().toCharArray());
if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) {
this.httpProxy = new HttpHost(configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort());
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java
index 79c3fad266..7cef64e576 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java
@@ -2,11 +2,11 @@
/**
*
- * 默认接口实现类,使用apache httpclient实现
+ * 默认接口实现类,使用apache httpClient 5实现
* Created by Binary Wang on 2017-5-27.
*
*
* @author Binary Wang
*/
-public class WxMpServiceImpl extends WxMpServiceHttpClientImpl {
+public class WxMpServiceImpl extends WxMpServiceHttpComponentsImpl {
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassOpenIdsMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassOpenIdsMessage.java
index 80e1658c16..936996ef69 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassOpenIdsMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassOpenIdsMessage.java
@@ -25,11 +25,11 @@ public class WxMpMassOpenIdsMessage implements Serializable {
/**
*
* 请使用
- * {@link WxConsts.MassMsgType#IMAGE}
- * {@link WxConsts.MassMsgType#MPNEWS}
- * {@link WxConsts.MassMsgType#TEXT}
- * {@link WxConsts.MassMsgType#MPVIDEO}
- * {@link WxConsts.MassMsgType#VOICE}
+ * {@link me.chanjar.weixin.common.api.WxConsts.MassMsgType#IMAGE}
+ * {@link me.chanjar.weixin.common.api.WxConsts.MassMsgType#MPNEWS}
+ * {@link me.chanjar.weixin.common.api.WxConsts.MassMsgType#TEXT}
+ * {@link me.chanjar.weixin.common.api.WxConsts.MassMsgType#MPVIDEO}
+ * {@link me.chanjar.weixin.common.api.WxConsts.MassMsgType#VOICE}
* 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
*
*/
@@ -60,6 +60,8 @@ public String toJson() {
/**
* 添加openid,最多支持10,000个
+ *
+ * @param openid 用户openid
*/
public void addUser(String openid) {
this.toUsers.add(openid);
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassPreviewMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassPreviewMessage.java
index dca743c9c3..57b34d352a 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassPreviewMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassPreviewMessage.java
@@ -19,11 +19,11 @@ public class WxMpMassPreviewMessage implements Serializable {
*
* 消息类型
* 请使用
- * {@link WxConsts.MassMsgType#IMAGE}
- * {@link WxConsts.MassMsgType#MPNEWS}
- * {@link WxConsts.MassMsgType#TEXT}
- * {@link WxConsts.MassMsgType#MPVIDEO}
- * {@link WxConsts.MassMsgType#VOICE}
+ * {@link me.chanjar.weixin.common.api.WxConsts.MassMsgType#IMAGE}
+ * {@link me.chanjar.weixin.common.api.WxConsts.MassMsgType#MPNEWS}
+ * {@link me.chanjar.weixin.common.api.WxConsts.MassMsgType#TEXT}
+ * {@link me.chanjar.weixin.common.api.WxConsts.MassMsgType#MPVIDEO}
+ * {@link me.chanjar.weixin.common.api.WxConsts.MassMsgType#VOICE}
* 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
*
*/
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 598e5754f1..466ef8d96f 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
@@ -24,11 +24,11 @@ public class WxMpMassTagMessage implements Serializable {
*
* 消息类型.
* 请使用
- * {@link WxConsts.MassMsgType#IMAGE}
- * {@link WxConsts.MassMsgType#MPNEWS}
- * {@link WxConsts.MassMsgType#TEXT}
- * {@link WxConsts.MassMsgType#MPVIDEO}
- * {@link WxConsts.MassMsgType#VOICE}
+ * {@link me.chanjar.weixin.common.api.WxConsts.MassMsgType#IMAGE}
+ * {@link me.chanjar.weixin.common.api.WxConsts.MassMsgType#MPNEWS}
+ * {@link me.chanjar.weixin.common.api.WxConsts.MassMsgType#TEXT}
+ * {@link me.chanjar.weixin.common.api.WxConsts.MassMsgType#MPVIDEO}
+ * {@link me.chanjar.weixin.common.api.WxConsts.MassMsgType#VOICE}
* 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
*
*/
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 9e73b46159..ac4a596dd8 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
@@ -63,9 +63,8 @@ public WxMpUserQuery add(String openid, String lang) {
/**
* 添加一个OpenId到列表中,并返回本对象
*
- *
* 该方法默认lang = zh_CN
- *
+ *
*
* @param openid openid
* @return {@link WxMpUserQuery}
@@ -100,6 +99,8 @@ public WxMpUserQuery remove(String openid, String lang) {
/**
* 获取查询参数列表
+ *
+ * @return 查询参数列表
*/
public List getQueryParamList() {
return this.queryParamList;
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/WxMpCardMpnewsGethtmlResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/WxMpCardMpnewsGethtmlResult.java
index 6d7dde1ad6..34a9c56b99 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/WxMpCardMpnewsGethtmlResult.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/WxMpCardMpnewsGethtmlResult.java
@@ -8,7 +8,9 @@
/**
- * @author S
+ * 卡券图文消息HTML结果
+ *
+ * @author S (sshzh90@gmail.com)
*/
@Data
public class WxMpCardMpnewsGethtmlResult implements Serializable {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/MemberCardActivateUserFormRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/MemberCardActivateUserFormRequest.java
index d8634cfa3c..0adb413869 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/MemberCardActivateUserFormRequest.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/MemberCardActivateUserFormRequest.java
@@ -39,8 +39,8 @@ public class MemberCardActivateUserFormRequest implements Serializable {
/**
* 绑定老会员卡信息
*
- * @param name
- * @param url
+ * @param name 名称
+ * @param url 链接地址
*/
public void setBindOldCard(String name, String url) {
if (StringUtils.isAnyEmpty(name, url)) {
@@ -56,8 +56,8 @@ public void setBindOldCard(String name, String url) {
/**
* 设置服务声明,用于放置商户会员卡守则
*
- * @param name
- * @param url
+ * @param name 名称
+ * @param url 链接地址
*/
public void setServiceStatement(String name, String url) {
if (StringUtils.isAnyEmpty(name, url)) {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/MemberCardUserForm.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/MemberCardUserForm.java
index 0c0fae3e2b..b3b0c9be5e 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/MemberCardUserForm.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/MemberCardUserForm.java
@@ -50,6 +50,7 @@ public class MemberCardUserForm implements Serializable {
/**
* 添加富文本类型字段
*
+ * @param field 富文本字段
*/
public void addRichField(MemberCardUserFormRichField field) {
if (field == null) {
@@ -64,6 +65,7 @@ public void addRichField(MemberCardUserFormRichField field) {
/**
* 添加微信选项类型字段
*
+ * @param fieldType 微信字段类型
*/
public void addWechatField(CardWechatFieldType fieldType) {
if (fieldType == null) {
@@ -78,6 +80,7 @@ public void addWechatField(CardWechatFieldType fieldType) {
/**
* 添加文本类型字段
*
+ * @param field 文本字段
*/
public void addCustomField(String field) {
if (StringUtils.isBlank(field)) {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/NotifyOptional.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/NotifyOptional.java
index 139db68557..1ba8a0e60c 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/NotifyOptional.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/NotifyOptional.java
@@ -6,12 +6,13 @@
import java.io.Serializable;
/**
- *
* 控制原生消息结构体,包含各字段的消息控制字段。
- *
+ *
* 用于 `7 更新会员信息` 的接口参数调用
- * https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025283
- *
+ *
+ *
+ * {@code 参考:会员卡接口}
+ *
*
* @author YuJian(mgcnrx11@gmail.com)
* @version 2017/7/15
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/WxMpMemberCardUpdateResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/WxMpMemberCardUpdateResult.java
index 663fe1f1e5..b4ad8eb139 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/WxMpMemberCardUpdateResult.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/WxMpMemberCardUpdateResult.java
@@ -6,10 +6,10 @@
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
/**
- *
* 用于 `7 更新会员信息` 的接口调用后的返回结果
- * https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025283
- *
+ *
+ * {@code 参考:会员卡接口}
+ *
*
* @author YuJian(mgcnrx11@gmail.com)
* @version 2017/7/15
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/WxMpMemberCardUserInfoResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/WxMpMemberCardUserInfoResult.java
index 8fad40ccf8..9a2b47f5bf 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/WxMpMemberCardUserInfoResult.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/card/membercard/WxMpMemberCardUserInfoResult.java
@@ -6,11 +6,10 @@
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
/**
- *
* 拉取会员信息返回的结果
- *
- * 字段格式参考https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025283 6.2.1小节的步骤5
- *
+ *
+ * {@code 字段格式参考:会员卡接口 6.2.1小节的步骤5}
+ *
*
* @author YuJian
* @version 2017/7/9
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java
index f066c1d934..01be3c08d2 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java
@@ -45,6 +45,8 @@ public class WxMpKefuMessage implements Serializable {
/**
* 获得文本消息builder.
+ *
+ * @return 文本消息builder
*/
public static TextBuilder TEXT() {
return new TextBuilder();
@@ -52,6 +54,8 @@ public static TextBuilder TEXT() {
/**
* 获得图片消息builder.
+ *
+ * @return 图片消息builder
*/
public static ImageBuilder IMAGE() {
return new ImageBuilder();
@@ -59,6 +63,8 @@ public static ImageBuilder IMAGE() {
/**
* 获得语音消息builder.
+ *
+ * @return 语音消息builder
*/
public static VoiceBuilder VOICE() {
return new VoiceBuilder();
@@ -66,6 +72,8 @@ public static VoiceBuilder VOICE() {
/**
* 获得视频消息builder.
+ *
+ * @return 视频消息builder
*/
public static VideoBuilder VIDEO() {
return new VideoBuilder();
@@ -73,6 +81,8 @@ public static VideoBuilder VIDEO() {
/**
* 获得音乐消息builder.
+ *
+ * @return 音乐消息builder
*/
public static MusicBuilder MUSIC() {
return new MusicBuilder();
@@ -80,6 +90,8 @@ public static MusicBuilder MUSIC() {
/**
* 获得图文消息(点击跳转到外链)builder.
+ *
+ * @return 图文消息builder
*/
public static NewsBuilder NEWS() {
return new NewsBuilder();
@@ -87,6 +99,8 @@ public static NewsBuilder NEWS() {
/**
* 获得图文消息(点击跳转到图文消息页面)builder.
+ *
+ * @return 图文消息builder
*/
public static MpNewsBuilder MPNEWS() {
return new MpNewsBuilder();
@@ -94,6 +108,8 @@ public static MpNewsBuilder MPNEWS() {
/**
* 获得卡券消息builder.
+ *
+ * @return 卡券消息builder
*/
public static WxCardBuilder WXCARD() {
return new WxCardBuilder();
@@ -101,6 +117,8 @@ public static WxCardBuilder WXCARD() {
/**
* 获得菜单消息builder.
+ *
+ * @return 菜单消息builder
*/
public static WxMsgMenuBuilder MSGMENU() {
return new WxMsgMenuBuilder();
@@ -108,20 +126,25 @@ public static WxMsgMenuBuilder MSGMENU() {
/**
* 小程序卡片.
+ *
+ * @return 小程序卡片builder
*/
public static MiniProgramPageBuilder MINIPROGRAMPAGE() {
return new MiniProgramPageBuilder();
}
/**
- * 发送图文消息(点击跳转到图文消息页面)使用通过 “发布” 系列接口得到的 article_id(草稿箱功能上线后不再支持客服接口中带 media_id 的 mpnews 类型的图文消息)
+ * 发送图文消息(点击跳转到图文消息页面)使用通过 “发布” 系列接口得到的 article_id
+ *
+ * @return 图文消息builder
*/
public static MpNewsArticleBuilder MPNEWSARTICLE() {
return new MpNewsArticleBuilder();
}
/**
- *
+ * 设置消息类型
+ *
* 请使用
* {@link me.chanjar.weixin.common.api.WxConsts.KefuMsgType#TEXT}
* {@link me.chanjar.weixin.common.api.WxConsts.KefuMsgType#IMAGE}
@@ -135,7 +158,9 @@ public static MpNewsArticleBuilder MPNEWSARTICLE() {
* {@link me.chanjar.weixin.common.api.WxConsts.KefuMsgType#TASKCARD}
* {@link me.chanjar.weixin.common.api.WxConsts.KefuMsgType#MSGMENU}
* {@link me.chanjar.weixin.common.api.WxConsts.KefuMsgType#MP_NEWS_ARTICLE}
- *
+ *
+ *
+ * @param msgType 消息类型
*/
public void setMsgType(String msgType) {
this.msgType = msgType;
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java
index 3d5f4ac3a0..dfc88ab13b 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java
@@ -927,6 +927,7 @@ public static WxMpXmlMessage fromXml(InputStream is) {
* @param timestamp 时间戳
* @param nonce 随机串
* @param msgSignature 签名串
+ * @return 解密后的消息对象
*/
public static WxMpXmlMessage fromEncryptedXml(String encryptedXml, WxMpConfigStorage wxMpConfigStorage,
String timestamp, String nonce, String msgSignature) {
@@ -956,14 +957,16 @@ public WxMpXmlMessage decryptField(WxMpConfigStorage wxMpConfigStorage,
/**
*
* 当接受用户消息时,可能会获得以下值:
- * {@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}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#TEXT}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#IMAGE}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#VOICE}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#VIDEO}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#LOCATION}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#LINK}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#EVENT}
*
+ *
+ * @return 消息类型
*/
public String getMsgType() {
return this.msgType;
@@ -972,13 +975,15 @@ public String getMsgType() {
/**
*
* 当发送消息的时候使用:
- * {@link WxConsts.XmlMsgType#TEXT}
- * {@link WxConsts.XmlMsgType#IMAGE}
- * {@link WxConsts.XmlMsgType#VOICE}
- * {@link WxConsts.XmlMsgType#VIDEO}
- * {@link WxConsts.XmlMsgType#NEWS}
- * {@link WxConsts.XmlMsgType#MUSIC}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#TEXT}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#IMAGE}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#VOICE}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#VIDEO}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#NEWS}
+ * {@link me.chanjar.weixin.common.api.WxConsts.XmlMsgType#MUSIC}
*
+ *
+ * @param msgType 消息类型
*/
public void setMsgType(String msgType) {
this.msgType = msgType;
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 a44aea740c..1f3143df7e 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
@@ -70,6 +70,8 @@ public abstract class WxMpXmlOutMessage implements Serializable {
/**
* 获得文本消息builder
+ *
+ * @return 文本消息构建器
*/
public static TextBuilder TEXT() {
return new TextBuilder();
@@ -77,6 +79,8 @@ public static TextBuilder TEXT() {
/**
* 获得图片消息builder
+ *
+ * @return 图片消息构建器
*/
public static ImageBuilder IMAGE() {
return new ImageBuilder();
@@ -84,6 +88,8 @@ public static ImageBuilder IMAGE() {
/**
* 获得语音消息builder
+ *
+ * @return 语音消息构建器
*/
public static VoiceBuilder VOICE() {
return new VoiceBuilder();
@@ -91,6 +97,8 @@ public static VoiceBuilder VOICE() {
/**
* 获得视频消息builder
+ *
+ * @return 视频消息构建器
*/
public static VideoBuilder VIDEO() {
return new VideoBuilder();
@@ -98,6 +106,8 @@ public static VideoBuilder VIDEO() {
/**
* 获得音乐消息builder
+ *
+ * @return 音乐消息构建器
*/
public static MusicBuilder MUSIC() {
return new MusicBuilder();
@@ -105,6 +115,8 @@ public static MusicBuilder MUSIC() {
/**
* 获得图文消息builder
+ *
+ * @return 图文消息构建器
*/
public static NewsBuilder NEWS() {
return new NewsBuilder();
@@ -112,6 +124,8 @@ public static NewsBuilder NEWS() {
/**
* 获得客服消息builder
+ *
+ * @return 客服消息构建器
*/
public static TransferCustomerServiceBuilder TRANSFER_CUSTOMER_SERVICE() {
return new TransferCustomerServiceBuilder();
@@ -119,11 +133,18 @@ public static TransferCustomerServiceBuilder TRANSFER_CUSTOMER_SERVICE() {
/**
* 获得设备消息builder
+ *
+ * @return 设备消息builder
*/
public static DeviceBuilder DEVICE() {
return new DeviceBuilder();
}
+ /**
+ * 转换成xml格式
+ *
+ * @return xml格式字符串
+ */
@SuppressWarnings("unchecked")
public String toXml() {
return XStreamTransformer.toXml((Class) this.getClass(), this);
@@ -131,6 +152,9 @@ public String toXml() {
/**
* 转换成加密的结果
+ *
+ * @param wxMpConfigStorage 公众号配置
+ * @return 加密后的消息对象
*/
public WxMpXmlOutMessage toEncrypted(WxMpConfigStorage wxMpConfigStorage) {
String plainXml = toXml();
@@ -146,6 +170,9 @@ public WxMpXmlOutMessage toEncrypted(WxMpConfigStorage wxMpConfigStorage) {
/**
* 转换成加密的xml格式
+ *
+ * @param wxMpConfigStorage 公众号配置
+ * @return 加密后的xml格式字符串
*/
public String toEncryptedXml(WxMpConfigStorage wxMpConfigStorage) {
String plainXml = toXml();
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassGetResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassGetResult.java
index fe8f6e4043..58f2ea2693 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassGetResult.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassGetResult.java
@@ -9,7 +9,8 @@
/**
*
* 查询群发消息发送状态【订阅号与服务号认证后均可用】
- * https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Batch_Sends_and_Originality_Checks.html#%E6%9F%A5%E8%AF%A2%E7%BE%A4%E5%8F%91%E6%B6%88%E6%81%AF%E5%8F%91%E9%80%81%E7%8A%B6%E6%80%81%E3%80%90%E8%AE%A2%E9%98%85%E5%8F%B7%E4%B8%8E%E6%9C%8D%E5%8A%A1%E5%8F%B7%E8%AE%A4%E8%AF%81%E5%90%8E%E5%9D%87%E5%8F%AF%E7%94%A8%E3%80%91
+ * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Batch_Sends_and_Originality_Checks.html
+ *
* @author S
*/
@Data
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/WxMpConfigStorage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/WxMpConfigStorage.java
index 11aeef6124..1bebe86885 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/WxMpConfigStorage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/WxMpConfigStorage.java
@@ -24,7 +24,7 @@ public interface WxMpConfigStorage {
* Is use stable access token api
*
* @return the boolean
- * @link https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/getStableAccessToken.html
+ * @see 文档
*/
boolean isStableAccessToken();
@@ -211,6 +211,8 @@ public interface WxMpConfigStorage {
*
* {@link me.chanjar.weixin.mp.api.impl.BaseWxMpServiceImpl#setRetrySleepMillis(int)}
*
+ *
+ * @return 重试间隔毫秒数
*/
int getRetrySleepMillis();
@@ -219,6 +221,8 @@ public interface WxMpConfigStorage {
*
* {@link me.chanjar.weixin.mp.api.impl.BaseWxMpServiceImpl#setMaxRetryTimes(int)}
*
+ *
+ * @return 最大重试次数
*/
int getMaxRetryTimes();
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpRedisConfigImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpRedisConfigImpl.java
index 870fa1e276..7939d57a18 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpRedisConfigImpl.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpRedisConfigImpl.java
@@ -39,6 +39,8 @@ public WxMpRedisConfigImpl(WxRedisOps redisOps, String keyPrefix) {
/**
* 每个公众号生成独有的存储key.
+ *
+ * @param appId 公众号appId
*/
@Override
public void setAppId(String appId) {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpRedissonConfigImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpRedissonConfigImpl.java
index e0d9e92af1..4982336f8a 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpRedissonConfigImpl.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpRedissonConfigImpl.java
@@ -42,6 +42,8 @@ private WxMpRedissonConfigImpl(@NonNull WxRedisOps redisOps, String keyPrefix) {
/**
* 每个公众号生成独有的存储key.
+ *
+ * @param appId 公众号appId
*/
@Override
public void setAppId(String appId) {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/constant/WxMpEventConstants.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/constant/WxMpEventConstants.java
index b2e984b0f9..4dfee6295e 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/constant/WxMpEventConstants.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/constant/WxMpEventConstants.java
@@ -20,7 +20,7 @@ public class WxMpEventConstants {
public static final String SUBMIT_MEMBERCARD_USER_INFO = "submit_membercard_user_info";
/**
- * 微信摇一摇周边>>摇一摇事件通知.
+ * 微信摇一摇周边-摇一摇事件通知.
*/
public static final String SHAKEAROUND_USER_SHAKE = "ShakearoundUserShake";
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/crypto/WxMpCryptUtil.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/crypto/WxMpCryptUtil.java
index 99d759f32f..7757ad78bf 100755
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/crypto/WxMpCryptUtil.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/crypto/WxMpCryptUtil.java
@@ -27,7 +27,7 @@ public class WxMpCryptUtil extends me.chanjar.weixin.common.util.crypto.WxCryptU
/**
* 构造函数
*
- * @param wxMpConfigStorage
+ * @param wxMpConfigStorage 公众号配置存储
*/
public WxMpCryptUtil(WxMpConfigStorage wxMpConfigStorage) {
/*
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/xml/XStreamTransformer.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/xml/XStreamTransformer.java
index ace711a236..55e92700de 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/xml/XStreamTransformer.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/xml/XStreamTransformer.java
@@ -33,7 +33,12 @@ public class XStreamTransformer {
}
/**
- * xml -> pojo.
+ * {@code xml -> pojo.}
+ *
+ * @param 返回类型
+ * @param clazz 类型
+ * @param xml xml字符串
+ * @return 转换后的对象
*/
@SuppressWarnings("unchecked")
public static T fromXml(Class clazz, String xml) {
@@ -41,6 +46,14 @@ public static T fromXml(Class clazz, String xml) {
return object;
}
+ /**
+ * {@code xml -> pojo.}
+ *
+ * @param 返回类型
+ * @param clazz 类型
+ * @param is 输入流
+ * @return 转换后的对象
+ */
@SuppressWarnings("unchecked")
public static T fromXml(Class clazz, InputStream is) {
T object = (T) CLASS_2_XSTREAM_INSTANCE.get(clazz).fromXML(is);
@@ -48,7 +61,12 @@ public static T fromXml(Class clazz, InputStream is) {
}
/**
- * pojo -> xml.
+ * {@code pojo -> xml.}
+ *
+ * @param 类型参数
+ * @param clazz 类型
+ * @param object 对象
+ * @return xml字符串
*/
public static String toXml(Class clazz, T object) {
return CLASS_2_XSTREAM_INSTANCE.get(clazz).toXML(object);
diff --git a/weixin-java-open/AUDIT_QUOTA_MANAGEMENT_GUIDE.md b/weixin-java-open/AUDIT_QUOTA_MANAGEMENT_GUIDE.md
new file mode 100644
index 0000000000..d84932034a
--- /dev/null
+++ b/weixin-java-open/AUDIT_QUOTA_MANAGEMENT_GUIDE.md
@@ -0,0 +1,321 @@
+# 微信开放平台小程序审核额度管理最佳实践
+
+## 问题背景
+
+在使用微信开放平台第三方服务为多个授权小程序提交审核时,需要注意以下重要限制:
+
+### 审核额度限制
+
+- **默认额度**: 每个第三方平台账号每月默认有 **20 个** 审核额度
+- **消耗规则**: 每次调用 `submitAudit()` 提交一个小程序审核,会消耗 **1 个** 审核额度
+- **重置周期**: 额度每月初自动重置
+- **不可返还**: 审核撤回(undoCodeAudit)不会返还已消耗的额度
+- **增加额度**: 如需更多额度,需要联系微信开放平台客服申请
+
+### 常见问题
+
+**问题**: 开放平台是每个 appId 都要这样提交审核吗?额度不够吧?
+
+**回答**: 是的,每个授权的小程序(appId)都需要单独调用 `submitAudit()` 提交审核,每次提交会消耗 1 个审核额度。默认的 20 个额度对于管理大量小程序的第三方平台来说可能不够用,建议:
+1. 提交审核前先查询剩余额度
+2. 合理规划审核计划,避免重复提交审核
+3. 联系微信开放平台申请增加额度
+
+## API 使用说明
+
+### 1. 查询审核额度
+
+```java
+// 查询当前审核额度
+WxOpenMaQueryQuotaResult quota = wxOpenMaService.queryQuota();
+
+System.out.println("当月剩余提交审核次数: " + quota.getRest()); // 剩余额度
+System.out.println("当月提交审核额度上限: " + quota.getLimit()); // 总额度
+System.out.println("剩余加急次数: " + quota.getSpeedupRest()); // 剩余加急次数
+System.out.println("加急额度上限: " + quota.getSpeedupLimit()); // 加急额度上限
+```
+
+**返回字段说明**:
+- `rest`: 当月剩余提交审核次数
+- `limit`: 当月提交审核额度上限(默认 20)
+- `speedupRest`: 剩余加急次数
+- `speedupLimit`: 加急额度上限
+
+### 2. 提交审核
+
+```java
+// 构建审核项
+WxMaCodeSubmitAuditItem item = new WxMaCodeSubmitAuditItem();
+item.setAddress("index"); // 页面路径
+item.setTag("工具"); // 标签
+item.setFirstClass("工具"); // 一级类目
+item.setSecondClass("效率"); // 二级类目
+item.setTitle("首页"); // 页面标题
+
+// 构建提交审核消息
+WxOpenMaSubmitAuditMessage message = new WxOpenMaSubmitAuditMessage();
+message.setItemList(Collections.singletonList(item));
+message.setVersionDesc("版本描述");
+
+// 提交审核
+WxOpenMaSubmitAuditResult result = wxOpenMaService.submitAudit(message);
+System.out.println("审核ID: " + result.getAuditId());
+```
+
+## 最佳实践
+
+### 方案一:单个小程序提交前检查额度
+
+这是最基本的做法,适用于偶尔提交审核的场景。
+
+```java
+import me.chanjar.weixin.open.api.WxOpenMaService;
+import me.chanjar.weixin.open.bean.message.WxOpenMaSubmitAuditMessage;
+import me.chanjar.weixin.open.bean.result.WxOpenMaQueryQuotaResult;
+import me.chanjar.weixin.open.bean.result.WxOpenMaSubmitAuditResult;
+import me.chanjar.weixin.common.error.WxErrorException;
+
+public class AuditSubmitter {
+
+ /**
+ * 提交审核前检查额度
+ */
+ public WxOpenMaSubmitAuditResult submitWithQuotaCheck(
+ WxOpenMaService wxOpenMaService,
+ WxOpenMaSubmitAuditMessage message) throws WxErrorException {
+
+ // 1. 检查审核额度
+ WxOpenMaQueryQuotaResult quota = wxOpenMaService.queryQuota();
+ System.out.println("当前剩余审核额度: " + quota.getRest());
+
+ if (quota.getRest() <= 0) {
+ throw new RuntimeException("审核额度不足,无法提交审核。剩余额度: " + quota.getRest());
+ }
+
+ // 2. 提交审核
+ WxOpenMaSubmitAuditResult result = wxOpenMaService.submitAudit(message);
+ System.out.println("提交审核成功,审核ID: " + result.getAuditId());
+
+ // 3. 再次查询额度(可选)
+ quota = wxOpenMaService.queryQuota();
+ System.out.println("提交后剩余审核额度: " + quota.getRest());
+
+ return result;
+ }
+}
+```
+
+### 方案二:批量提交审核的额度管理
+
+适用于需要同时为多个小程序提交审核的场景。
+
+```java
+import me.chanjar.weixin.open.api.WxOpenComponentService;
+import me.chanjar.weixin.open.api.WxOpenMaService;
+import me.chanjar.weixin.open.bean.message.WxOpenMaSubmitAuditMessage;
+import me.chanjar.weixin.open.bean.result.WxOpenMaQueryQuotaResult;
+import me.chanjar.weixin.open.bean.result.WxOpenMaSubmitAuditResult;
+import me.chanjar.weixin.common.error.WxErrorException;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class BatchAuditSubmitter {
+
+ /**
+ * 批量提交审核结果
+ */
+ public static class BatchSubmitResult {
+ private int successCount; // 成功数量
+ private int failCount; // 失败数量
+ private int skipCount; // 跳过数量(额度不足)
+ private List failedAppIds; // 失败的 appId
+
+ // getters and setters...
+ }
+
+ /**
+ * 批量提交审核,带额度检查
+ */
+ public BatchSubmitResult batchSubmitWithQuotaCheck(
+ WxOpenComponentService wxOpenComponentService,
+ Map appIdToMessageMap) {
+
+ BatchSubmitResult result = new BatchSubmitResult();
+ result.setFailedAppIds(new ArrayList<>());
+
+ // 基本参数校验:避免空指针和空集合导致的 NoSuchElementException
+ if (appIdToMessageMap == null || appIdToMessageMap.isEmpty()) {
+ System.err.println("错误:待提交的小程序列表为空,未执行任何审核提交");
+ return result;
+ }
+
+ try {
+ // 1. 检查总体额度是否充足
+ // 使用任意一个已授权的小程序 appId 获取 WxMaService 来查询审核额度。
+ // 注意:审核额度是以第三方平台维度统计的,因此这里选择任意一个 appId 即可。
+ WxOpenMaQueryQuotaResult quota = wxOpenComponentService
+ .getWxMaServiceByAppid(appIdToMessageMap.keySet().iterator().next())
+ .queryQuota();
+
+ System.out.println("=== 批量提交审核开始 ===");
+ System.out.println("待提交数量: " + appIdToMessageMap.size());
+ System.out.println("当前剩余审核额度: " + quota.getRest());
+
+ if (quota.getRest() < appIdToMessageMap.size()) {
+ System.err.println("警告:审核额度不足!");
+ System.err.println(" 需要提交: " + appIdToMessageMap.size() + " 个");
+ System.err.println(" 剩余额度: " + quota.getRest());
+ System.err.println(" 缺少额度: " + (appIdToMessageMap.size() - quota.getRest()));
+ System.err.println("将仅提交前 " + quota.getRest() + " 个小程序");
+ }
+
+ // 2. 依次提交审核
+ int count = 0;
+ for (Map.Entry entry : appIdToMessageMap.entrySet()) {
+ String appId = entry.getKey();
+ WxOpenMaSubmitAuditMessage message = entry.getValue();
+
+ // 检查是否还有额度
+ if (count >= quota.getRest()) {
+ System.out.println("AppId: " + appId + " 跳过(额度不足)");
+ result.setSkipCount(result.getSkipCount() + 1);
+ continue;
+ }
+
+ try {
+ WxOpenMaService maService = wxOpenComponentService.getWxMaServiceByAppid(appId);
+ WxOpenMaSubmitAuditResult submitResult = maService.submitAudit(message);
+
+ System.out.println("AppId: " + appId + " 提交成功,审核ID: " + submitResult.getAuditId());
+ result.setSuccessCount(result.getSuccessCount() + 1);
+ count++;
+
+ } catch (WxErrorException e) {
+ System.err.println("AppId: " + appId + " 提交失败: " + e.getMessage());
+ result.setFailCount(result.getFailCount() + 1);
+ result.getFailedAppIds().add(appId);
+ count++;
+ }
+ }
+
+ // 3. 输出统计信息
+ System.out.println("=== 批量提交审核完成 ===");
+ System.out.println("成功: " + result.getSuccessCount());
+ System.out.println("失败: " + result.getFailCount());
+ System.out.println("跳过: " + result.getSkipCount());
+
+ // 4. 查询剩余额度
+ quota = wxOpenComponentService
+ .getWxMaServiceByAppid(appIdToMessageMap.keySet().iterator().next())
+ .queryQuota();
+ System.out.println("剩余额度: " + quota.getRest());
+
+ } catch (WxErrorException e) {
+ System.err.println("批量提交审核失败: " + e.getMessage());
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+}
+```
+
+### 方案三:审核额度监控和告警
+
+建议实现一个审核额度监控机制,及时发现额度不足的情况。
+
+```java
+import me.chanjar.weixin.open.api.WxOpenMaService;
+import me.chanjar.weixin.open.bean.result.WxOpenMaQueryQuotaResult;
+import me.chanjar.weixin.common.error.WxErrorException;
+
+public class QuotaMonitor {
+
+ /**
+ * 检查审核额度并发出告警
+ */
+ public void checkAndAlert(WxOpenMaService wxOpenMaService) {
+ try {
+ WxOpenMaQueryQuotaResult quota = wxOpenMaService.queryQuota();
+
+ int rest = quota.getRest();
+ int limit = quota.getLimit();
+ double percentage = (double) rest / limit * 100;
+
+ System.out.println("审核额度状态:");
+ System.out.println(" 剩余: " + rest + " / " + limit);
+ System.out.println(" 使用率: " + String.format("%.1f", 100 - percentage) + "%");
+
+ // 根据剩余额度发出不同级别的告警
+ if (rest <= 0) {
+ sendCriticalAlert("审核额度已用尽!无法提交新的审核。");
+ } else if (rest <= 3) {
+ sendWarningAlert("审核额度严重不足!剩余额度: " + rest);
+ } else if (percentage < 30) {
+ sendInfoAlert("审核额度偏低,剩余: " + rest + " (" + String.format("%.1f", percentage) + "%)");
+ }
+
+ } catch (WxErrorException e) {
+ System.err.println("查询审核额度失败: " + e.getMessage());
+ }
+ }
+
+ private void sendCriticalAlert(String message) {
+ // 发送紧急告警(如:发送邮件、短信、钉钉消息等)
+ System.err.println("[严重] " + message);
+ }
+
+ private void sendWarningAlert(String message) {
+ // 发送警告(如:发送邮件、企业微信消息等)
+ System.out.println("[警告] " + message);
+ }
+
+ private void sendInfoAlert(String message) {
+ // 发送普通提示
+ System.out.println("[提示] " + message);
+ }
+}
+```
+
+## 常见问题 FAQ
+
+### Q1: 审核额度什么时候重置?
+A: 审核额度在每月初自动重置为默认值(通常是 20 个)。
+
+### Q2: 审核撤回会返还额度吗?
+A: 不会。调用 `undoCodeAudit()` 撤回审核不会返还已消耗的额度。
+
+### Q3: 如何增加审核额度?
+A: 需要联系微信开放平台客服申请增加额度。具体联系方式请参考微信开放平台官方文档。
+
+### Q4: 审核失败会消耗额度吗?
+A: 会。只要调用了 `submitAudit()` 接口提交审核,无论审核是否通过,都会消耗 1 个额度。
+
+### Q5: 加急审核会额外消耗额度吗?
+A: 加急审核(`speedAudit()`)使用的是单独的加急额度(`speedupRest`),不会消耗普通审核额度。但加急审核的前提是已经提交了审核,所以提交审核时仍会消耗 1 个普通审核额度。
+
+### Q6: 多个小程序共享审核额度吗?
+A: 是的。同一个第三方平台账号下,所有授权的小程序共享审核额度。每提交一个小程序审核,都会消耗该第三方平台的 1 个审核额度。
+
+### Q7: 如何避免审核额度不足?
+A: 建议采取以下措施:
+- 在批量提交审核前,先调用 `queryQuota()` 检查剩余额度
+- 实现审核额度监控和告警机制
+- 合理规划审核计划,避免不必要的重复提交审核
+- 提高代码质量,减少审核不通过的情况
+- 联系微信开放平台申请增加额度
+
+### Q8: 能否查询历史审核额度使用情况?
+A: 微信开放平台 API 目前只提供当前剩余额度查询,不提供历史使用记录。如需统计历史使用情况,需要自行记录每次调用 `submitAudit()` 的时间和次数。
+
+## 相关文档
+
+- [微信开放平台官方文档 - 查询额度](https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/Mini_Programs/code/query_quota.html)
+- [微信开放平台官方文档 - 提交审核](https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/Mini_Programs/code/submit_audit.html)
+- [微信开放平台官方文档 - 加急审核](https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/Mini_Programs/code/speedup_audit.html)
+
+## 技术支持
+
+如有问题,请提交 Issue 到 [WxJava GitHub 仓库](https://github.com/binarywang/WxJava/issues)。
diff --git a/weixin-java-open/README.md b/weixin-java-open/README.md
index 6ca65dfef3..ad7f3d0109 100644
--- a/weixin-java-open/README.md
+++ b/weixin-java-open/README.md
@@ -31,6 +31,36 @@
---
+## 重要提示:小程序审核额度限制
+
+**在使用第三方平台代小程序提交审核时,请注意以下限制:**
+
+### 审核额度说明
+
+- **默认额度**: 每个第三方平台账号每月默认有 **20 个** 审核额度
+- **消耗规则**: 每次调用 `submitAudit()` 提交一个小程序审核,会消耗 **1 个** 审核额度
+- **重置周期**: 额度每月初自动重置
+- **额度查询**: 使用 `queryQuota()` 方法查询剩余额度
+
+### 最佳实践
+
+```java
+// 1. 先查询剩余额度
+WxOpenMaQueryQuotaResult quota = wxOpenMaService.queryQuota();
+if (quota.getRest() <= 0) {
+ throw new RuntimeException("审核额度不足,剩余:" + quota.getRest());
+}
+
+// 2. 提交审核
+WxOpenMaSubmitAuditMessage message = new WxOpenMaSubmitAuditMessage();
+message.setItemList(itemList);
+WxOpenMaSubmitAuditResult result = wxOpenMaService.submitAudit(message);
+```
+
+**详细说明**: 请参考 [AUDIT_QUOTA_MANAGEMENT_GUIDE.md](AUDIT_QUOTA_MANAGEMENT_GUIDE.md)
+
+---
+
## 代码示例
消息机制未实现,下面为通知回调中设置的代码部分
diff --git a/weixin-java-open/pom.xml b/weixin-java-open/pom.xml
index f354cb16f8..6720cd2b30 100644
--- a/weixin-java-open/pom.xml
+++ b/weixin-java-open/pom.xml
@@ -7,7 +7,7 @@
com.github.binarywang
wx-java
- 4.7.9.B
+ 4.8.0
weixin-java-open
@@ -48,6 +48,16 @@
okhttp
provided
+ * 重要提示:审核额度限制 + *
+ *+ * 最佳实践: + *
+ *{@code
+ * // 1. 先查询剩余额度
+ * WxOpenMaQueryQuotaResult quota = wxOpenMaService.queryQuota();
+ * if (quota.getRest() <= 0) {
+ * throw new RuntimeException("审核额度不足,剩余:" + quota.getRest());
+ * }
+ *
+ * // 2. 提交审核
+ * WxOpenMaSubmitAuditMessage message = new WxOpenMaSubmitAuditMessage();
+ * message.setItemList(itemList);
+ * WxOpenMaSubmitAuditResult result = wxOpenMaService.submitAudit(message);
+ * }
*
* @param submitAuditMessage the submit audit message
* @return the wx open ma submit audit result
* @throws WxErrorException the wx error exception
+ * @see #queryQuota() 查询审核额度
+ * @see #speedAudit(Long) 加急审核
*/
WxOpenMaSubmitAuditResult submitAudit(WxOpenMaSubmitAuditMessage submitAuditMessage) throws WxErrorException;
@@ -690,11 +716,43 @@ WxOpenMaDomainResult modifyDomainDirectly(String action, List+ * 文档地址: + * 查询额度 + *
+ *+ * 返回字段说明: + *
+ *+ * 重要说明: + *
+ *+ * 使用示例: + *
+ *{@code
+ * WxOpenMaQueryQuotaResult quota = wxOpenMaService.queryQuota();
+ * System.out.println("剩余审核次数:" + quota.getRest());
+ * System.out.println("审核额度上限:" + quota.getLimit());
+ * System.out.println("剩余加急次数:" + quota.getSpeedupRest());
+ * }
+ *
+ * @return 审核额度信息
+ * @throws WxErrorException 调用微信接口失败时抛出
+ * @see #submitAudit(WxOpenMaSubmitAuditMessage) 提交审核
+ * @see #speedAudit(Long) 加急审核
*/
WxOpenMaQueryQuotaResult queryQuota() throws WxErrorException;
diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMessageRouter.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMessageRouter.java
index 7314bfd694..3c2c3058f4 100644
--- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMessageRouter.java
+++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMessageRouter.java
@@ -23,4 +23,29 @@ public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, String appId) {
public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, final Map+ * 重要提示:审核额度限制 + *
+ *+ * 使用示例: + *
+ *{@code
+ * // 1. 构建审核项
+ * WxMaCodeSubmitAuditItem item = new WxMaCodeSubmitAuditItem();
+ * item.setAddress("index");
+ * item.setTag("游戏");
+ * item.setFirstClass("游戏");
+ * item.setSecondClass("休闲游戏");
+ * item.setTitle("首页");
+ *
+ * // 2. 构建提交审核消息
+ * WxOpenMaSubmitAuditMessage message = new WxOpenMaSubmitAuditMessage();
+ * message.setItemList(Collections.singletonList(item));
+ * message.setVersionDesc("版本描述");
+ *
+ * // 3. 提交审核
+ * WxOpenMaSubmitAuditResult result = wxOpenMaService.submitAudit(message);
+ * System.out.println("审核ID: " + result.getAuditId());
+ * }
*
* @author yqx
+ * @see me.chanjar.weixin.open.api.WxOpenMaService#submitAudit(WxOpenMaSubmitAuditMessage)
+ * @see me.chanjar.weixin.open.api.WxOpenMaService#queryQuota()
* created on 2018/9/13
*/
@Data
diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaQueryQuotaResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaQueryQuotaResult.java
index 3b02906242..0f964b5f44 100644
--- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaQueryQuotaResult.java
+++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaQueryQuotaResult.java
@@ -6,7 +6,31 @@
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
/**
- * 微信开放平台小程序当前分阶段发布详情
+ * 微信开放平台小程序提交审核额度查询结果
+ * + * 用于查询第三方平台服务商的当月提交审核限额和加急次数 + *
+ *+ * 字段说明: + *
+ *+ * 重要提示: + *
+ *+ * 这是一个完整的示例,展示如何在提交审核前检查额度,避免额度不足导致的失败 + *
+ */ + @Test + public void testSubmitAuditWithQuotaCheck() { + // 此测试方法演示提交审核前的额度检查最佳实践 + // 注意:实际运行需要真实的微信 API 凭据 + /* + try { + // 步骤1:检查审核额度 + WxOpenMaQueryQuotaResult quota = wxOpenMaService.queryQuota(); + System.out.println("当前剩余审核额度: " + quota.getRest()); + + if (quota.getRest() <= 0) { + throw new RuntimeException("审核额度不足,无法提交审核。剩余额度: " + quota.getRest()); + } + + // 步骤2:准备审核数据 + WxMaCodeSubmitAuditItem item = new WxMaCodeSubmitAuditItem(); + item.setAddress("index"); + item.setTag("工具"); + item.setFirstClass("工具"); + item.setSecondClass("效率"); + item.setTitle("首页"); + + WxOpenMaSubmitAuditMessage message = new WxOpenMaSubmitAuditMessage(); + message.setItemList(Collections.singletonList(item)); + message.setVersionDesc("修复若干已知问题,优化用户体验"); + + // 步骤3:提交审核 + WxOpenMaSubmitAuditResult result = wxOpenMaService.submitAudit(message); + System.out.println("提交审核成功,审核ID: " + result.getAuditId()); + + // 步骤4:再次查询额度,确认已消耗 + quota = wxOpenMaService.queryQuota(); + System.out.println("提交后剩余审核额度: " + quota.getRest()); + + } catch (WxErrorException e) { + System.err.println("提交审核失败: " + e.getMessage()); + e.printStackTrace(); + } + */ + } + + /** + * 演示批量提交审核时的额度管理策略 + *+ * 当需要为多个小程序提交审核时,应该先统一检查额度是否充足 + *
+ */ + @Test + public void testBatchSubmitAuditWithQuotaManagement() { + // 此测试方法演示批量提交审核时的额度管理策略 + // 注意:实际运行需要真实的微信 API 凭据,以及 WxOpenComponentService 实例 + /* + // 假设已经初始化了 wxOpenComponentService + // WxOpenComponentService wxOpenComponentService = ...; + + try { + // 假设需要为多个小程序提交审核 + List+ * 从业机构调用该接口向微信医保后台下单 + * 文档地址:https://pay.weixin.qq.com/doc/v3/partner/4012503131 + * @author xgl + * @date 2025/12/19 14:37 + */ +@Data +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class MedInsOrdersRequest { + + /** + *
+ * 字段名:混合支付类型 + * 变量名:mix_pay_type + * 必填:是 + * 类型:string + * 描述: + * 混合支付类型可选取值: + * - UNKNOWN_MIX_PAY_TYPE: 未知的混合支付类型,会被拦截 + * - CASH_ONLY: 只向微信支付下单,没有向医保局下单 + * - INSURANCE_ONLY: 只向医保局下单,没有向微信支付下单 + * - CASH_AND_INSURANCE: 向医保局下单,也向微信支付下单 + *+ */ + @SerializedName("mix_pay_type") + public MixPayTypeEnum mixPayType; + + /** + *
+ * 字段名:订单类型 + * 变量名:order_type + * 必填:是 + * 类型:string + * 描述: + * 订单类型可选取值: + * - UNKNOWN_ORDER_TYPE: 未知类型,会被拦截 + * - REG_PAY: 挂号支付 + * - DIAG_PAY: 诊间支付 + * - COVID_EXAM_PAY: 新冠检测费用(核酸) + * - IN_HOSP_PAY: 住院费支付 + * - PHARMACY_PAY: 药店支付 + * - INSURANCE_PAY: 保险费支付 + * - INT_REG_PAY: 互联网医院挂号支付 + * - INT_RE_DIAG_PAY: 互联网医院复诊支付 + * - INT_RX_PAY: 互联网医院处方支付 + * - COVID_ANTIGEN_PAY: 新冠抗原检测 + * - MED_PAY: 药费支付 + *+ */ + @SerializedName("order_type") + public OrderTypeEnum orderType; + + /** + *
+ * 字段名:从业机构/服务商的公众号ID + * 变量名:appid + * 必填:是 + * 类型:string(32) + * 描述:从业机构/服务商的公众号ID + *+ */ + @SerializedName("appid") + public String appid; + + /** + *
+ * 字段名:医疗机构的公众号ID + * 变量名:sub_appid + * 必填:是 + * 类型:string(32) + * 描述:医疗机构的公众号ID + *+ */ + @SerializedName("sub_appid") + public String subAppid; + + /** + *
+ * 字段名:医疗机构的商户号 + * 变量名:sub_mchid + * 必填:是 + * 类型:string(32) + * 描述:医疗机构的商户号 + *+ */ + @SerializedName("sub_mchid") + public String subMchid; + + /** + *
+ * 字段名:用户在appid下的唯一标识 + * 变量名:openid + * 必填:否 + * 类型:string(128) + * 描述:openid与sub_openid二选一,传入openid时需要使用appid调起医保自费混合支付 + *+ */ + @SerializedName("openid") + public String openid; + + /** + *
+ * 字段名:用户在sub_appid下的唯一标识 + * 变量名:sub_openid + * 必填:否 + * 类型:string(128) + * 描述:openid与sub_openid二选一,传入sub_openid时需要使用sub_appid调起医保自费混合支付 + *+ */ + @SerializedName("sub_openid") + public String subOpenid; + + /** + *
+ * 字段名:支付人身份信息 + * 变量名:payer + * 必填:是 + * 类型:object + * 描述:支付人身份信息 + *+ */ + @SerializedName("payer") + @SpecEncrypt + public PersonIdentification payer; + + /** + *
+ * 字段名:是否代亲属支付 + * 变量名:pay_for_relatives + * 必填:否 + * 类型:boolean + * 描述:不传默认替本人支付 + * - true: 代亲属支付 + * - false: 本人支付 + *+ */ + @SerializedName("pay_for_relatives") + public Boolean payForRelatives; + + /** + *
+ * 字段名:亲属身份信息 + * 变量名:relative + * 必填:否 + * 类型:object + * 描述:pay_for_relatives为true时,该字段必填 + *+ */ + @SerializedName("relative") + @SpecEncrypt + public PersonIdentification relative; + + /** + *
+ * 字段名:从业机构订单号 + * 变量名:out_trade_no + * 必填:是 + * 类型:string(64) + * 描述:从业机构/服务商需要调两次接口:从业机构/服务商向微信支付下单获取微信支付凭证,请求中会带上out_trade_no。下单成功后,从业机构/服务商调用混合下单的接口(即该接口),请求中也会带上out_trade_no。 + *+ */ + @SerializedName("out_trade_no") + public String outTradeNo; + + /** + *
+ * 字段名:医疗机构订单号 + * 变量名:serial_no + * 必填:是 + * 类型:string(40) + * 描述:例如医院HIS系统订单号。传与费用明细上传中medOrgOrd字段一样的值,局端会校验,不一致将会返回错误 + *+ */ + @SerializedName("serial_no") + public String serialNo; + + /** + *
+ * 字段名:支付订单号 + * 变量名:pay_order_id + * 必填:否 + * 类型:string + * 描述:支付订单号 + *+ */ + @SerializedName("pay_order_id") + public String payOrderId; + + /** + *
+ * 字段名:支付授权号 + * 变量名:pay_auth_no + * 必填:否 + * 类型:string + * 描述:支付授权号 + *+ */ + @SerializedName("pay_auth_no") + public String payAuthNo; + + /** + *
+ * 字段名:地理位置 + * 变量名:geo_location + * 必填:否 + * 类型:string + * 描述:地理位置 + *+ */ + @SerializedName("geo_location") + public String geoLocation; + + /** + *
+ * 字段名:城市ID + * 变量名:city_id + * 必填:否 + * 类型:string + * 描述:城市ID + *+ */ + @SerializedName("city_id") + public String cityId; + + /** + *
+ * 字段名:医疗机构名称 + * 变量名:med_inst_name + * 必填:否 + * 类型:string + * 描述:医疗机构名称 + *+ */ + @SerializedName("med_inst_name") + public String medInstName; + + /** + *
+ * 字段名:医疗机构编号 + * 变量名:med_inst_no + * 必填:否 + * 类型:string + * 描述:医疗机构编号 + *+ */ + @SerializedName("med_inst_no") + public String medInstNo; + + /** + *
+ * 字段名:医保订单创建时间 + * 变量名:med_ins_order_create_time + * 必填:否 + * 类型:string + * 描述:医保订单创建时间 + *+ */ + @SerializedName("med_ins_order_create_time") + public String medInsOrderCreateTime; + + /** + *
+ * 字段名:总金额 + * 变量名:total_fee + * 必填:否 + * 类型:Integer + * 描述:总金额 + *+ */ + @SerializedName("total_fee") + public Integer totalFee; + + /** + *
+ * 字段名:医保统筹基金支付金额 + * 变量名:med_ins_gov_fee + * 必填:否 + * 类型:Integer + * 描述:医保统筹基金支付金额 + *+ */ + @SerializedName("med_ins_gov_fee") + public Integer medInsGovFee; + + /** + *
+ * 字段名:医保个人账户支付金额 + * 变量名:med_ins_self_fee + * 必填:否 + * 类型:Integer + * 描述:医保个人账户支付金额 + *+ */ + @SerializedName("med_ins_self_fee") + public Integer medInsSelfFee; + + /** + *
+ * 字段名:医保其他基金支付金额 + * 变量名:med_ins_other_fee + * 必填:否 + * 类型:Integer + * 描述:医保其他基金支付金额 + *+ */ + @SerializedName("med_ins_other_fee") + public Integer medInsOtherFee; + + /** + *
+ * 字段名:医保现金支付金额 + * 变量名:med_ins_cash_fee + * 必填:否 + * 类型:Integer + * 描述:医保现金支付金额 + *+ */ + @SerializedName("med_ins_cash_fee") + public Integer medInsCashFee; + + /** + *
+ * 字段名:微信支付现金支付金额 + * 变量名:wechat_pay_cash_fee + * 必填:否 + * 类型:Integer + * 描述:微信支付现金支付金额 + *+ */ + @SerializedName("wechat_pay_cash_fee") + public Integer wechatPayCashFee; + + /** + *
+ * 字段名:现金增加明细 + * 变量名:cash_add_detail + * 必填:否 + * 类型:list + * 描述:现金增加明细 + *+ */ + @SerializedName("cash_add_detail") + public List
+ * 字段名:现金减少明细 + * 变量名:cash_reduce_detail + * 必填:否 + * 类型:list + * 描述:现金减少明细 + *+ */ + @SerializedName("cash_reduce_detail") + public List
+ * 字段名:回调URL + * 变量名:callback_url + * 必填:否 + * 类型:string + * 描述:回调URL + *+ */ + @SerializedName("callback_url") + public String callbackUrl; + + /** + *
+ * 字段名:预支付交易会话标识 + * 变量名:prepay_id + * 必填:否 + * 类型:string + * 描述:预支付交易会话标识 + *+ */ + @SerializedName("prepay_id") + public String prepayId; + + /** + *
+ * 字段名:透传请求内容 + * 变量名:passthrough_request_content + * 必填:否 + * 类型:string + * 描述:透传请求内容 + *+ */ + @SerializedName("passthrough_request_content") + public String passthroughRequestContent; + + /** + *
+ * 字段名:扩展字段 + * 变量名:extends + * 必填:否 + * 类型:string + * 描述:扩展字段 + *+ */ + @SerializedName("extends") + public String _extends; + + /** + *
+ * 字段名:附加数据 + * 变量名:attach + * 必填:否 + * 类型:string + * 描述:附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用 + *+ */ + @SerializedName("attach") + public String attach; + + /** + *
+ * 字段名:渠道编号 + * 变量名:channel_no + * 必填:否 + * 类型:string + * 描述:渠道编号 + *+ */ + @SerializedName("channel_no") + public String channelNo; + + /** + *
+ * 字段名:医保测试环境标识 + * 变量名:med_ins_test_env + * 必填:否 + * 类型:boolean + * 描述:医保测试环境标识 + *+ */ + @SerializedName("med_ins_test_env") + public Boolean medInsTestEnv; + + /** + *
+ * 支付人身份信息 + *+ */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @Accessors(chain = true) + public static class PersonIdentification { + /** + *
+ * 字段名:姓名 + * 变量名:name + * 必填:是 + * 类型:string + * 描述:姓名,需加密 + *+ */ + @SerializedName("name") + @SpecEncrypt + public String name; + + /** + *
+ * 字段名:身份证摘要 + * 变量名:id_digest + * 必填:是 + * 类型:string + * 描述:身份证摘要,需加密 + *+ */ + @SerializedName("id_digest") + @SpecEncrypt + public String idDigest; + + /** + *
+ * 字段名:证件类型 + * 变量名:card_type + * 必填:是 + * 类型:string + * 描述:证件类型 + *+ */ + @SerializedName("card_type") + public UserCardTypeEnum cardType; + } + + /** + *
+ * 现金增加明细实体 + *+ */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @Accessors(chain = true) + public static class CashAddEntity { + /** + *
+ * 字段名:现金增加金额 + * 变量名:cash_add_fee + * 必填:是 + * 类型:Integer + * 描述:现金增加金额 + *+ */ + @SerializedName("cash_add_fee") + public Integer cashAddFee; + + /** + *
+ * 字段名:现金增加类型 + * 变量名:cash_add_type + * 必填:是 + * 类型:string + * 描述:现金增加类型 + *+ */ + @SerializedName("cash_add_type") + public CashAddTypeEnum cashAddType; + } + + /** + *
+ * 现金减少明细实体 + *+ */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @Accessors(chain = true) + public static class CashReduceEntity { + /** + *
+ * 字段名:现金减少金额 + * 变量名:cash_reduce_fee + * 必填:是 + * 类型:Integer + * 描述:现金减少金额 + *+ */ + @SerializedName("cash_reduce_fee") + public Integer cashReduceFee; + + /** + *
+ * 字段名:现金减少类型 + * 变量名:cash_reduce_type + * 必填:是 + * 类型:string + * 描述:现金减少类型 + *+ */ + @SerializedName("cash_reduce_type") + public CashReduceTypeEnum cashReduceType; + } + + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/MedInsOrdersResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/MedInsOrdersResult.java new file mode 100644 index 0000000000..9a119d8723 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/MedInsOrdersResult.java @@ -0,0 +1,497 @@ +package com.github.binarywang.wxpay.bean.mipay; + +import com.github.binarywang.wxpay.bean.mipay.enums.MedInsPayStatusEnum; +import com.github.binarywang.wxpay.bean.mipay.enums.MixPayStatusEnum; +import com.github.binarywang.wxpay.bean.mipay.enums.MixPayTypeEnum; +import com.github.binarywang.wxpay.bean.mipay.enums.OrderTypeEnum; +import com.github.binarywang.wxpay.bean.mipay.enums.SelfPayStatusEnum; +import com.google.gson.annotations.SerializedName; +import java.util.List; +import lombok.Data; + +/** + * 医保自费混合收款下单响应 + *
+ * 从业机构调用医保自费混合收款下单接口后返回的结果 + * 文档地址:https://pay.weixin.qq.com/doc/v3/partner/4012503131 + * @author xgl + * @date 2025/12/19 14:37 + */ +@Data +public class MedInsOrdersResult { + /** + *
+ * 字段名:混合交易订单号 + * 变量名:mix_trade_no + * 必填:是 + * 类型:string + * 描述:微信支付生成的混合交易订单号 + *+ */ + @SerializedName("mix_trade_no") + public String mixTradeNo; + + /** + *
+ * 字段名:混合支付状态 + * 变量名:mix_pay_status + * 必填:是 + * 类型:string + * 描述:混合支付整体状态 + *+ */ + @SerializedName("mix_pay_status") + public MixPayStatusEnum mixPayStatus; + + /** + *
+ * 字段名:自费支付状态 + * 变量名:self_pay_status + * 必填:是 + * 类型:string + * 描述:自费部分支付状态 + *+ */ + @SerializedName("self_pay_status") + public SelfPayStatusEnum selfPayStatus; + + /** + *
+ * 字段名:医保支付状态 + * 变量名:med_ins_pay_status + * 必填:是 + * 类型:string + * 描述:医保部分支付状态 + *+ */ + @SerializedName("med_ins_pay_status") + public MedInsPayStatusEnum medInsPayStatus; + + /** + *
+ * 字段名:支付完成时间 + * 变量名:paid_time + * 必填:否 + * 类型:string + * 描述:支付完成时间,格式为yyyyMMddHHmmss + *+ */ + @SerializedName("paid_time") + public String paidTime; + + /** + *
+ * 字段名:透传响应内容 + * 变量名:passthrough_response_content + * 必填:否 + * 类型:string + * 描述:透传响应内容 + *+ */ + @SerializedName("passthrough_response_content") + public String passthroughResponseContent; + + /** + *
+ * 字段名:混合支付类型 + * 变量名:mix_pay_type + * 必填:是 + * 类型:string + * 描述: + * 混合支付类型可选取值: + * - UNKNOWN_MIX_PAY_TYPE: 未知的混合支付类型,会被拦截 + * - CASH_ONLY: 只向微信支付下单,没有向医保局下单 + * - INSURANCE_ONLY: 只向医保局下单,没有向微信支付下单 + * - CASH_AND_INSURANCE: 向医保局下单,也向微信支付下单 + *+ */ + @SerializedName("mix_pay_type") + public MixPayTypeEnum mixPayType; + + /** + *
+ * 字段名:订单类型 + * 变量名:order_type + * 必填:是 + * 类型:string + * 描述: + * 订单类型可选取值: + * - UNKNOWN_ORDER_TYPE: 未知类型,会被拦截 + * - REG_PAY: 挂号支付 + * - DIAG_PAY: 诊间支付 + * - COVID_EXAM_PAY: 新冠检测费用(核酸) + * - IN_HOSP_PAY: 住院费支付 + * - PHARMACY_PAY: 药店支付 + * - INSURANCE_PAY: 保险费支付 + * - INT_REG_PAY: 互联网医院挂号支付 + * - INT_RE_DIAG_PAY: 互联网医院复诊支付 + * - INT_RX_PAY: 互联网医院处方支付 + * - COVID_ANTIGEN_PAY: 新冠抗原检测 + * - MED_PAY: 药费支付 + *+ */ + @SerializedName("order_type") + public OrderTypeEnum orderType; + + /** + *
+ * 字段名:从业机构/服务商的公众号ID + * 变量名:appid + * 必填:是 + * 类型:string(32) + * 描述:从业机构/服务商的公众号ID + *+ */ + @SerializedName("appid") + public String appid; + + /** + *
+ * 字段名:医疗机构的公众号ID + * 变量名:sub_appid + * 必填:是 + * 类型:string(32) + * 描述:医疗机构的公众号ID + *+ */ + @SerializedName("sub_appid") + public String subAppid; + + /** + *
+ * 字段名:医疗机构的商户号 + * 变量名:sub_mchid + * 必填:是 + * 类型:string(32) + * 描述:医疗机构的商户号 + *+ */ + @SerializedName("sub_mchid") + public String subMchid; + + /** + *
+ * 字段名:用户在appid下的唯一标识 + * 变量名:openid + * 必填:否 + * 类型:string(128) + * 描述:openid与sub_openid二选一,传入openid时需要使用appid调起医保自费混合支付 + *+ */ + @SerializedName("openid") + public String openid; + + /** + *
+ * 字段名:用户在sub_appid下的唯一标识 + * 变量名:sub_openid + * 必填:否 + * 类型:string(128) + * 描述:openid与sub_openid二选一,传入sub_openid时需要使用sub_appid调起医保自费混合支付 + *+ */ + @SerializedName("sub_openid") + public String subOpenid; + + /** + *
+ * 字段名:是否代亲属支付 + * 变量名:pay_for_relatives + * 必填:否 + * 类型:boolean + * 描述:不传默认替本人支付 + * - true: 代亲属支付 + * - false: 本人支付 + *+ */ + @SerializedName("pay_for_relatives") + public Boolean payForRelatives; + + /** + *
+ * 字段名:从业机构订单号 + * 变量名:out_trade_no + * 必填:是 + * 类型:string(64) + * 描述:从业机构/服务商需要调两次接口:从业机构/服务商向微信支付下单获取微信支付凭证,请求中会带上out_trade_no。下单成功后,从业机构/服务商调用混合下单的接口(即该接口),请求中也会带上out_trade_no。 + *+ */ + @SerializedName("out_trade_no") + public String outTradeNo; + + /** + *
+ * 字段名:医疗机构订单号 + * 变量名:serial_no + * 必填:是 + * 类型:string(40) + * 描述:例如医院HIS系统订单号。传与费用明细上传中medOrgOrd字段一样的值,局端会校验,不一致将会返回错误 + *+ */ + @SerializedName("serial_no") + public String serialNo; + + /** + *
+ * 字段名:支付订单号 + * 变量名:pay_order_id + * 必填:否 + * 类型:string + * 描述:支付订单号 + *+ */ + @SerializedName("pay_order_id") + public String payOrderId; + + /** + *
+ * 字段名:支付授权号 + * 变量名:pay_auth_no + * 必填:否 + * 类型:string + * 描述:支付授权号 + *+ */ + @SerializedName("pay_auth_no") + public String payAuthNo; + + /** + *
+ * 字段名:地理位置 + * 变量名:geo_location + * 必填:否 + * 类型:string + * 描述:地理位置 + *+ */ + @SerializedName("geo_location") + public String geoLocation; + + /** + *
+ * 字段名:城市ID + * 变量名:city_id + * 必填:否 + * 类型:string + * 描述:城市ID + *+ */ + @SerializedName("city_id") + public String cityId; + + /** + *
+ * 字段名:医疗机构名称 + * 变量名:med_inst_name + * 必填:否 + * 类型:string + * 描述:医疗机构名称 + *+ */ + @SerializedName("med_inst_name") + public String medInstName; + + /** + *
+ * 字段名:医疗机构编号 + * 变量名:med_inst_no + * 必填:否 + * 类型:string + * 描述:医疗机构编号 + *+ */ + @SerializedName("med_inst_no") + public String medInstNo; + + /** + *
+ * 字段名:医保订单创建时间 + * 变量名:med_ins_order_create_time + * 必填:否 + * 类型:string + * 描述:医保订单创建时间 + *+ */ + @SerializedName("med_ins_order_create_time") + public String medInsOrderCreateTime; + + /** + *
+ * 字段名:总金额 + * 变量名:total_fee + * 必填:否 + * 类型:Integer + * 描述:总金额 + *+ */ + @SerializedName("total_fee") + public Integer totalFee; + + /** + *
+ * 字段名:医保统筹基金支付金额 + * 变量名:med_ins_gov_fee + * 必填:否 + * 类型:Integer + * 描述:医保统筹基金支付金额 + *+ */ + @SerializedName("med_ins_gov_fee") + public Integer medInsGovFee; + + /** + *
+ * 字段名:医保个人账户支付金额 + * 变量名:med_ins_self_fee + * 必填:否 + * 类型:Integer + * 描述:医保个人账户支付金额 + *+ */ + @SerializedName("med_ins_self_fee") + public Integer medInsSelfFee; + + /** + *
+ * 字段名:医保其他基金支付金额 + * 变量名:med_ins_other_fee + * 必填:否 + * 类型:Integer + * 描述:医保其他基金支付金额 + *+ */ + @SerializedName("med_ins_other_fee") + public Integer medInsOtherFee; + + /** + *
+ * 字段名:医保现金支付金额 + * 变量名:med_ins_cash_fee + * 必填:否 + * 类型:Integer + * 描述:医保现金支付金额 + *+ */ + @SerializedName("med_ins_cash_fee") + public Integer medInsCashFee; + + /** + *
+ * 字段名:微信支付现金支付金额 + * 变量名:wechat_pay_cash_fee + * 必填:否 + * 类型:Integer + * 描述:微信支付现金支付金额 + *+ */ + @SerializedName("wechat_pay_cash_fee") + public Integer wechatPayCashFee; + + /** + *
+ * 字段名:现金增加明细 + * 变量名:cash_add_detail + * 必填:否 + * 类型:list + * 描述:现金增加明细 + *+ */ + @SerializedName("cash_add_detail") + public List
+ * 字段名:现金减少明细 + * 变量名:cash_reduce_detail + * 必填:否 + * 类型:list + * 描述:现金减少明细 + *+ */ + @SerializedName("cash_reduce_detail") + public List
+ * 字段名:回调URL + * 变量名:callback_url + * 必填:否 + * 类型:string + * 描述:回调URL + *+ */ + @SerializedName("callback_url") + public String callbackUrl; + + /** + *
+ * 字段名:预支付交易会话标识 + * 变量名:prepay_id + * 必填:否 + * 类型:string + * 描述:预支付交易会话标识 + *+ */ + @SerializedName("prepay_id") + public String prepayId; + + /** + *
+ * 字段名:透传请求内容 + * 变量名:passthrough_request_content + * 必填:否 + * 类型:string + * 描述:透传请求内容 + *+ */ + @SerializedName("passthrough_request_content") + public String passthroughRequestContent; + + /** + *
+ * 字段名:扩展字段 + * 变量名:extends + * 必填:否 + * 类型:string + * 描述:扩展字段 + *+ */ + @SerializedName("extends") + public String _extends; + + /** + *
+ * 字段名:附加数据 + * 变量名:attach + * 必填:否 + * 类型:string + * 描述:附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用 + *+ */ + @SerializedName("attach") + public String attach; + + /** + *
+ * 字段名:渠道编号 + * 变量名:channel_no + * 必填:否 + * 类型:string + * 描述:渠道编号 + *+ */ + @SerializedName("channel_no") + public String channelNo; + + /** + *
+ * 字段名:医保测试环境标识 + * 变量名:med_ins_test_env + * 必填:否 + * 类型:boolean + * 描述:医保测试环境标识 + *+ */ + @SerializedName("med_ins_test_env") + public Boolean medInsTestEnv; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/MedInsRefundNotifyRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/MedInsRefundNotifyRequest.java new file mode 100644 index 0000000000..cb935b52cd --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/MedInsRefundNotifyRequest.java @@ -0,0 +1,106 @@ +package com.github.binarywang.wxpay.bean.mipay; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 医保退款通知请求 + *
+ * 从业机构调用该接口向微信医保后台通知医保订单的退款成功结果 + * 文档地址:https://pay.weixin.qq.com/doc/v3/partner/4012166534 + * @author xgl + * @date 2025/12/20 + */ +@Data +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +public class MedInsRefundNotifyRequest { + + /** + *
+ * 字段名:医疗机构的商户号 + * 变量名:sub_mchid + * 必填:是 + * 类型:string(32) + * 描述:医疗机构的商户号 + *+ */ + @SerializedName("sub_mchid") + private String subMchid; + + /** + *
+ * 字段名:医保退款的总金额 + * 变量名:med_refund_total_fee + * 必填:是 + * 类型:integer + * 描述:单位分,医保退款的总金额。 + *+ */ + @SerializedName("med_refund_total_fee") + private Integer medRefundTotalFee; + + /** + *
+ * 字段名:医保统筹退款金额 + * 变量名:med_refund_gov_fee + * 必填:是 + * 类型:integer + * 描述:单位分,医保统筹退款金额。 + *+ */ + @SerializedName("med_refund_gov_fee") + private Integer medRefundGovFee; + + /** + *
+ * 字段名:医保个账退款金额 + * 变量名:med_refund_self_fee + * 必填:是 + * 类型:integer + * 描述:单位分,医保个账退款金额。 + *+ */ + @SerializedName("med_refund_self_fee") + private Integer medRefundSelfFee; + + /** + *
+ * 字段名:医保其他退款金额 + * 变量名:med_refund_other_fee + * 必填:是 + * 类型:integer + * 描述:单位分,医保其他退款金额。 + *+ */ + @SerializedName("med_refund_other_fee") + private Integer medRefundOtherFee; + + /** + *
+ * 字段名:医保退款成功时间 + * 变量名:refund_time + * 必填:是 + * 类型:string(64) + * 描述:遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE。 + *+ */ + @SerializedName("refund_time") + private String refundTime; + + /** + *
+ * 字段名:从业机构\服务商退款单号 + * 变量名:out_refund_no + * 必填:是 + * 类型:string(64) + * 描述:有自费单时,从业机构\服务商应填与自费退款申请处一致的out_refund_no。否则从业机构透传医疗机构退款单号即可。 + *+ */ + @SerializedName("out_refund_no") + private String outRefundNo; +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/CashAddTypeEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/CashAddTypeEnum.java new file mode 100644 index 0000000000..b935f20410 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/CashAddTypeEnum.java @@ -0,0 +1,29 @@ +package com.github.binarywang.wxpay.bean.mipay.enums; + +import com.google.gson.annotations.SerializedName; + +/** + * 现金增加类型枚举 + *
+ * 描述医保自费混合支付中现金增加的类型 + * + * @author xgl + * @date 2025/12/20 + */ +public enum CashAddTypeEnum { + /** + * 默认增加类型 + */ + @SerializedName("DEFAULT_ADD_TYPE") + DEFAULT_ADD_TYPE, + /** + * 运费 + */ + @SerializedName("FREIGHT") + FREIGHT, + /** + * 其他医疗费用 + */ + @SerializedName("OTHER_MEDICAL_EXPENSES") + OTHER_MEDICAL_EXPENSES +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/CashReduceTypeEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/CashReduceTypeEnum.java new file mode 100644 index 0000000000..4f90b8500a --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/CashReduceTypeEnum.java @@ -0,0 +1,44 @@ +package com.github.binarywang.wxpay.bean.mipay.enums; + +import com.google.gson.annotations.SerializedName; + +/** + * 现金减少类型枚举 + *
+ * 描述医保自费混合支付中现金减少的类型 + * + * @author xgl + * @date 2025/12/20 + */ +public enum CashReduceTypeEnum { + /** + * 默认减少类型 + */ + @SerializedName("DEFAULT_REDUCE_TYPE") + DEFAULT_REDUCE_TYPE, + /** + * 医院减免 + */ + @SerializedName("HOSPITAL_REDUCE") + HOSPITAL_REDUCE, + /** + * 药店折扣 + */ + @SerializedName("PHARMACY_DISCOUNT") + PHARMACY_DISCOUNT, + /** + * 折扣优惠 + */ + @SerializedName("DISCOUNT") + DISCOUNT, + /** + * 预付费抵扣 + */ + @SerializedName("PRE_PAYMENT") + PRE_PAYMENT, + /** + * 押金扣除 + */ + @SerializedName("DEPOSIT_DEDUCTION") + DEPOSIT_DEDUCTION +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/MedInsPayStatusEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/MedInsPayStatusEnum.java new file mode 100644 index 0000000000..324530f0ff --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/MedInsPayStatusEnum.java @@ -0,0 +1,44 @@ +package com.github.binarywang.wxpay.bean.mipay.enums; + +import com.google.gson.annotations.SerializedName; + +/** + * 医保支付状态枚举 + *
+ * 描述医保自费混合支付中医保部分的支付状态 + * + * @author xgl + * @date 2025/12/20 + */ +public enum MedInsPayStatusEnum { + /** + * 未知的医保支付状态 + */ + @SerializedName("UNKNOWN_MED_INS_PAY_STATUS") + UNKNOWN_MED_INS_PAY_STATUS, + /** + * 医保支付已创建 + */ + @SerializedName("MED_INS_PAY_CREATED") + MED_INS_PAY_CREATED, + /** + * 医保支付成功 + */ + @SerializedName("MED_INS_PAY_SUCCESS") + MED_INS_PAY_SUCCESS, + /** + * 医保支付已退款 + */ + @SerializedName("MED_INS_PAY_REFUND") + MED_INS_PAY_REFUND, + /** + * 医保支付失败 + */ + @SerializedName("MED_INS_PAY_FAIL") + MED_INS_PAY_FAIL, + /** + * 无需医保支付 + */ + @SerializedName("NO_MED_INS_PAY") + NO_MED_INS_PAY +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/MixPayStatusEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/MixPayStatusEnum.java new file mode 100644 index 0000000000..7360704986 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/MixPayStatusEnum.java @@ -0,0 +1,39 @@ +package com.github.binarywang.wxpay.bean.mipay.enums; + +import com.google.gson.annotations.SerializedName; + +/** + * 混合支付状态枚举 + *
+ * 描述医保自费混合支付的整体状态 + * + * @author xgl + * @date 2025/12/20 + */ +public enum MixPayStatusEnum { + /** + * 未知的混合支付状态 + */ + @SerializedName("UNKNOWN_MIX_PAY_STATUS") + UNKNOWN_MIX_PAY_STATUS, + /** + * 混合支付已创建 + */ + @SerializedName("MIX_PAY_CREATED") + MIX_PAY_CREATED, + /** + * 混合支付成功 + */ + @SerializedName("MIX_PAY_SUCCESS") + MIX_PAY_SUCCESS, + /** + * 混合支付已退款 + */ + @SerializedName("MIX_PAY_REFUND") + MIX_PAY_REFUND, + /** + * 混合支付失败 + */ + @SerializedName("MIX_PAY_FAIL") + MIX_PAY_FAIL +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/MixPayTypeEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/MixPayTypeEnum.java new file mode 100644 index 0000000000..ad62d50a66 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/MixPayTypeEnum.java @@ -0,0 +1,41 @@ +package com.github.binarywang.wxpay.bean.mipay.enums; + +import com.google.gson.annotations.SerializedName; + +/** + * 混合支付类型枚举 + *
+ * 描述医保自费混合支付的类型 + * 文档地址:https://pay.weixin.qq.com/doc/v3/partner/4012503131 + * + * @author xgl + * @date 2025/12/20 09:21 + */ +public enum MixPayTypeEnum { + + /** + * 未知的混合支付类型,会被拦截。 + */ + @SerializedName("UNKNOWN_MIX_PAY_TYPE") + UNKNOWN_MIX_PAY_TYPE, + + /** + * 只向微信支付下单,没有向医保局下单。包括没有向医保局上传费用明细、预结算。 + */ + @SerializedName("CASH_ONLY") + CASH_ONLY, + + /** + * 只向医保局下单,没有向微信支付下单。如果医保局分账结果中有自费部份,但由于有减免抵扣,没有向微信支付下单,也是纯医保。 + */ + @SerializedName("INSURANCE_ONLY") + INSURANCE_ONLY, + + /** + * 向医保局下单,也向微信支付下单。如果医保预结算全部需自费,也属于混合类型。 + */ + @SerializedName("CASH_AND_INSURANCE") + CASH_AND_INSURANCE + + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/OrderTypeEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/OrderTypeEnum.java new file mode 100644 index 0000000000..749b1276e7 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/OrderTypeEnum.java @@ -0,0 +1,87 @@ +package com.github.binarywang.wxpay.bean.mipay.enums; + +import com.google.gson.annotations.SerializedName; + +/** + * 订单类型枚举 + *
+ * 描述医保自费混合支付的订单类型 + * 文档地址:https://pay.weixin.qq.com/doc/v3/partner/4012503131 + * + * @author xgl + * @date 2025/12/20 + */ +public enum OrderTypeEnum { + + /** + * 未知类型,会被拦截 + */ + @SerializedName("UNKNOWN_ORDER_TYPE") + UNKNOWN_ORDER_TYPE, + + /** + * 挂号支付 + */ + @SerializedName("REG_PAY") + REG_PAY, + + /** + * 诊间支付 + */ + @SerializedName("DIAG_PAY") + DIAG_PAY, + + /** + * 新冠检测费用(核酸) + */ + @SerializedName("COVID_EXAM_PAY") + COVID_EXAM_PAY, + + /** + * 住院费支付 + */ + @SerializedName("IN_HOSP_PAY") + IN_HOSP_PAY, + + /** + * 药店支付 + */ + @SerializedName("PHARMACY_PAY") + PHARMACY_PAY, + + /** + * 保险费支付 + */ + @SerializedName("INSURANCE_PAY") + INSURANCE_PAY, + + /** + * 互联网医院挂号支付 + */ + @SerializedName("INT_REG_PAY") + INT_REG_PAY, + + /** + * 互联网医院复诊支付 + */ + @SerializedName("INT_RE_DIAG_PAY") + INT_RE_DIAG_PAY, + + /** + * 互联网医院处方支付 + */ + @SerializedName("INT_RX_PAY") + INT_RX_PAY, + + /** + * 新冠抗原检测 + */ + @SerializedName("COVID_ANTIGEN_PAY") + COVID_ANTIGEN_PAY, + + /** + * 药费支付 + */ + @SerializedName("MED_PAY") + MED_PAY +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/SelfPayStatusEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/SelfPayStatusEnum.java new file mode 100644 index 0000000000..a7014b9e13 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/SelfPayStatusEnum.java @@ -0,0 +1,44 @@ +package com.github.binarywang.wxpay.bean.mipay.enums; + +import com.google.gson.annotations.SerializedName; + +/** + * 自费支付状态枚举 + *
+ * 描述医保自费混合支付中自费部分的支付状态 + * + * @author xgl + * @date 2025/12/20 + */ +public enum SelfPayStatusEnum { + /** + * 未知的自费支付状态 + */ + @SerializedName("UNKNOWN_SELF_PAY_STATUS") + UNKNOWN_SELF_PAY_STATUS, + /** + * 自费支付已创建 + */ + @SerializedName("SELF_PAY_CREATED") + SELF_PAY_CREATED, + /** + * 自费支付成功 + */ + @SerializedName("SELF_PAY_SUCCESS") + SELF_PAY_SUCCESS, + /** + * 自费支付已退款 + */ + @SerializedName("SELF_PAY_REFUND") + SELF_PAY_REFUND, + /** + * 自费支付失败 + */ + @SerializedName("SELF_PAY_FAIL") + SELF_PAY_FAIL, + /** + * 无需自费支付 + */ + @SerializedName("NO_SELF_PAY") + NO_SELF_PAY +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/UserCardTypeEnum.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/UserCardTypeEnum.java new file mode 100644 index 0000000000..1bf97b7628 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/mipay/enums/UserCardTypeEnum.java @@ -0,0 +1,54 @@ +package com.github.binarywang.wxpay.bean.mipay.enums; + +import com.google.gson.annotations.SerializedName; + +/** + * 用户证件类型枚举 + *
+ * 描述医保自费混合支付中用户的证件类型 + * + * @author xgl + * @date 2025/12/20 + */ +public enum UserCardTypeEnum { + /** + * 未知的用户证件类型 + */ + @SerializedName("UNKNOWN_USER_CARD_TYPE") + UNKNOWN_USER_CARD_TYPE, + /** + * 居民身份证 + */ + @SerializedName("ID_CARD") + ID_CARD, + /** + * 户口本 + */ + @SerializedName("HOUSEHOLD_REGISTRATION") + HOUSEHOLD_REGISTRATION, + /** + * 外国护照 + */ + @SerializedName("FOREIGNER_PASSPORT") + FOREIGNER_PASSPORT, + /** + * 台湾居民来往大陆通行证 + */ + @SerializedName("MAINLAND_TRAVEL_PERMIT_FOR_TW") + MAINLAND_TRAVEL_PERMIT_FOR_TW, + /** + * 澳门居民来往大陆通行证 + */ + @SerializedName("MAINLAND_TRAVEL_PERMIT_FOR_MO") + MAINLAND_TRAVEL_PERMIT_FOR_MO, + /** + * 香港居民来往大陆通行证 + */ + @SerializedName("MAINLAND_TRAVEL_PERMIT_FOR_HK") + MAINLAND_TRAVEL_PERMIT_FOR_HK, + /** + * 外国人永久居留身份证 + */ + @SerializedName("FOREIGN_PERMANENT_RESIDENT") + FOREIGN_PERMANENT_RESIDENT +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/MiPayNotifyV3Result.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/MiPayNotifyV3Result.java new file mode 100644 index 0000000000..346d427fc4 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/MiPayNotifyV3Result.java @@ -0,0 +1,265 @@ +package com.github.binarywang.wxpay.bean.notify; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *
+ * 医保混合收款成功通知结果 + * 文档地址:https://pay.weixin.qq.com/doc/v3/partner/4012165722 + *+ * + * @author xgl + * @since 2025/12/20 + */ +@Data +@NoArgsConstructor +public class MiPayNotifyV3Result implements Serializable, WxPayBaseNotifyV3Result
+ * 字段名:应用ID + * 变量名:appid + * 是否必填:是 + * 类型:string(32) + * 描述: + * 从业机构/服务商的公众号ID + *+ */ + @SerializedName(value = "appid") + private String appid; + + /** + *
+ * 字段名:医疗机构的公众号ID + * 变量名:sub_appid + * 是否必填:是 + * 类型:string(32) + * 描述: + * 医疗机构的公众号ID + *+ */ + @SerializedName(value = "sub_appid") + private String subAppid; + + /** + *
+ * 字段名:医疗机构的商户号 + * 变量名:sub_mchid + * 是否必填:是 + * 类型:string(32) + * 描述: + * 医疗机构的商户号 + *+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + + /** + *
+ * 字段名:从业机构订单号 + * 变量名:out_trade_no + * 是否必填:是 + * 类型:string(64) + * 描述: + * 从业机构/服务商订单号 + *+ */ + @SerializedName(value = "out_trade_no") + private String outTradeNo; + + /** + *
+ * 字段名:医保自费混合订单号 + * 变量名:mix_trade_no + * 是否必填:是 + * 类型:string(32) + * 描述: + * 微信支付系统生成的医保自费混合订单号 + *+ */ + @SerializedName(value = "mix_trade_no") + private String mixTradeNo; + + /** + *
+ * 字段名:微信支付订单号 + * 变量名:transaction_id + * 是否必填:是 + * 类型:string(32) + * 描述: + * 微信支付系统生成的订单号 + *+ */ + @SerializedName(value = "transaction_id") + private String transactionId; + + /** + *
+ * 字段名:医保订单创建时间 + * 变量名:med_ins_order_create_time + * 是否必填:是 + * 类型:string(64) + * 描述: + * 医保订单创建时间,遵循rfc3339标准格式 + *+ */ + @SerializedName(value = "med_ins_order_create_time") + private String medInsOrderCreateTime; + + /** + *
+ * 字段名:医保订单完成时间 + * 变量名:med_ins_order_finish_time + * 是否必填:是 + * 类型:string(64) + * 描述: + * 医保订单完成时间,遵循rfc3339标准格式 + *+ */ + @SerializedName(value = "med_ins_order_finish_time") + private String medInsOrderFinishTime; + + /** + *
+ * 字段名:总金额 + * 变量名:total_fee + * 是否必填:否 + * 类型:long + * 描述: + * 总金额,单位为分 + *+ */ + @SerializedName(value = "total_fee") + private Long totalFee; + + /** + *
+ * 字段名:医保统筹基金支付金额 + * 变量名:med_ins_gov_fee + * 是否必填:否 + * 类型:long + * 描述: + * 医保统筹基金支付金额,单位为分 + *+ */ + @SerializedName(value = "med_ins_gov_fee") + private Long medInsGovFee; + + /** + *
+ * 字段名:医保个人账户支付金额 + * 变量名:med_ins_self_fee + * 是否必填:否 + * 类型:long + * 描述: + * 医保个人账户支付金额,单位为分 + *+ */ + @SerializedName(value = "med_ins_self_fee") + private Long medInsSelfFee; + + /** + *
+ * 字段名:医保其他基金支付金额 + * 变量名:med_ins_other_fee + * 是否必填:否 + * 类型:long + * 描述: + * 医保其他基金支付金额,单位为分 + *+ */ + @SerializedName(value = "med_ins_other_fee") + private Long medInsOtherFee; + + /** + *
+ * 字段名:医保现金支付金额 + * 变量名:med_ins_cash_fee + * 是否必填:否 + * 类型:long + * 描述: + * 医保现金支付金额,单位为分 + *+ */ + @SerializedName(value = "med_ins_cash_fee") + private Long medInsCashFee; + + /** + *
+ * 字段名:微信支付现金支付金额 + * 变量名:wechat_pay_cash_fee + * 是否必填:否 + * 类型:long + * 描述: + * 微信支付现金支付金额,单位为分 + *+ */ + @SerializedName(value = "wechat_pay_cash_fee") + private Long wechatPayCashFee; + + /** + *
+ * 字段名:附加数据 + * 变量名:attach + * 是否必填:否 + * 类型:string(128) + * 描述: + * 附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用 + *+ */ + @SerializedName(value = "attach") + private String attach; + + /** + *
+ * 字段名:支付状态 + * 变量名:trade_state + * 是否必填:是 + * 类型:string(32) + * 描述: + * 交易状态,枚举值: + * SUCCESS:支付成功 + * REFUND:转入退款 + * NOTPAY:未支付 + * CLOSED:已关闭 + * REVOKED:已撤销 + * USERPAYING:用户支付中 + * PAYERROR:支付失败 + *+ */ + @SerializedName(value = "trade_state") + private String tradeState; + + /** + *
+ * 字段名:支付状态描述 + * 变量名:trade_state_desc + * 是否必填:是 + * 类型:string(256) + * 描述: + * 交易状态描述 + *+ */ + @SerializedName(value = "trade_state_desc") + private String tradeStateDesc; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayBaseNotifyV3Result.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayBaseNotifyV3Result.java index 86915d0956..364c9080d8 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayBaseNotifyV3Result.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayBaseNotifyV3Result.java @@ -5,7 +5,8 @@ * * @author Pursuer * @version 1.0 - * @date 2023/6/15 + * @since 2023/6/15 + * @param
+ * 微信支付实名验证请求对象. + * 详见文档:https://pay.wechatpay.cn/doc/v2/merchant/4011987607 + *+ * + * @author Binary Wang + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +@XStreamAlias("xml") +public class RealNameRequest extends BaseWxPayRequest { + private static final long serialVersionUID = 1L; + + /** + *
+ * 字段名:用户标识 + * 变量名:openid + * 是否必填:是 + * 类型:String(128) + * 示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o + * 描述:用户在商户appid下的唯一标识 + *+ */ + @Required + @XStreamAlias("openid") + private String openid; + + @Override + protected void checkConstraints() { + //do nothing + } + + @Override + protected void storeMap(Map
+ * 微信支付实名验证返回结果. + * 详见文档:https://pay.wechatpay.cn/doc/v2/merchant/4011987607 + *+ * + * @author Binary Wang + */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@XStreamAlias("xml") +public class RealNameResult extends BaseWxPayResult implements Serializable { + private static final long serialVersionUID = 1L; + + /** + *
+ * 字段名:用户标识 + * 变量名:openid + * 是否必填:否 + * 类型:String(128) + * 示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o + * 描述:用户在商户appid下的唯一标识 + *+ */ + @XStreamAlias("openid") + private String openid; + + /** + *
+ * 字段名:实名认证状态 + * 变量名:is_certified + * 是否必填:是 + * 类型:String(1) + * 示例值:Y + * 描述:Y-已实名认证 N-未实名认证 + *+ */ + @XStreamAlias("is_certified") + private String isCertified; + + /** + *
+ * 字段名:实名认证信息 + * 变量名:cert_info + * 是否必填:否 + * 类型:String(256) + * 示例值: + * 描述:实名认证的相关信息,如姓名等(加密) + *+ */ + @XStreamAlias("cert_info") + private String certInfo; + + /** + *
+ * 字段名:引导链接 + * 变量名:guide_url + * 是否必填:否 + * 类型:String(256) + * 示例值: + * 描述:未实名时,引导用户进行实名认证的URL + *+ */ + @XStreamAlias("guide_url") + private String guideUrl; + + /** + * 从XML结构中加载额外的属性 + * + * @param d Document + */ + @Override + protected void loadXml(Document d) { + openid = readXmlString(d, "openid"); + isCertified = readXmlString(d, "is_certified"); + certInfo = readXmlString(d, "cert_info"); + guideUrl = readXmlString(d, "guide_url"); + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayCodepayRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayCodepayRequest.java index ecfa614a16..632561075a 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayCodepayRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayCodepayRequest.java @@ -45,6 +45,58 @@ public class WxPayCodepayRequest implements Serializable { */ @SerializedName(value = "mchid") protected String mchid; + /** + *
+ * 字段名:服务商应用ID + * 变量名:sp_appid + * 是否必填:否 + * 类型:string[1,32] + * 描述: + * 服务商模式下使用,由微信生成的应用ID,全局唯一。 + * 示例值:wxd678efh567hg6787 + *+ */ + @SerializedName(value = "sp_appid") + protected String spAppid; + /** + *
+ * 字段名:服务商商户号 + * 变量名:sp_mchid + * 是否必填:否 + * 类型:string[1,32] + * 描述: + * 服务商模式下使用,服务商商户号,由微信支付生成并下发。 + * 示例值:1230000109 + *+ */ + @SerializedName(value = "sp_mchid") + protected String spMchid; + /** + *
+ * 字段名:子商户应用ID + * 变量名:sub_appid + * 是否必填:否 + * 类型:string[1,32] + * 描述: + * 服务商模式下使用,由微信生成的应用ID,全局唯一。 + * 示例值:wxd678efh567hg6787 + *+ */ + @SerializedName(value = "sub_appid") + protected String subAppid; + /** + *
+ * 字段名:子商户商户号 + * 变量名:sub_mchid + * 是否必填:否 + * 类型:string[1,32] + * 描述: + * 服务商模式下使用,子商户商户号,由微信支付生成并下发。 + * 示例值:1230000109 + *+ */ + @SerializedName(value = "sub_mchid") + protected String subMchid; /** *
* 字段名:商品描述
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 e145644d91..b0cbcf4e70 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
@@ -230,7 +230,9 @@ public void checkAndSign(WxPayConfig config) throws WxPayException {
if (StringUtils.isBlank(this.getOpUserId())) {
this.setOpUserId(config.getMchId());
}
-
+ if (StringUtils.isBlank(this.getNotifyUrl())) {
+ this.setNotifyUrl(config.getRefundNotifyUrl());
+ }
super.checkAndSign(config);
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderV3Result.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderV3Result.java
index 309fb8e752..5b60f3b520 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderV3Result.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderV3Result.java
@@ -58,7 +58,7 @@ public class WxPayUnifiedOrderV3Result implements Serializable {
/**
*
* 字段名:二维码链接(NATIVE支付 会返回)
- * 变量名:h5_url
+ * 变量名:code_url
* 是否必填:是
* 类型:string[1,512]
* 描述:
@@ -81,6 +81,19 @@ public static class JsapiResult implements Serializable {
private String packageValue;
private String signType;
private String paySign;
+ /**
+ *
+ * 字段名:预支付交易会话标识
+ * 变量名:prepay_id
+ * 是否必填:否(用户可选存储)
+ * 类型:string[1,64]
+ * 描述:
+ * 预支付交易会话标识。用于后续接口调用中使用,该值有效期为2小时
+ * 此字段用于支持用户存储prepay_id,以便复用和重新生成支付签名
+ * 示例值:wx201410272009395522657a690389285100
+ *
+ */
+ private String prepayId;
private String getSignStr() {
return String.format("%s\n%s\n%s\n%s\n", appId, timeStamp, nonceStr, packageValue);
@@ -106,30 +119,123 @@ private String getSignStr() {
}
public T getPayInfo(TradeTypeEnum tradeType, String appId, String mchId, PrivateKey privateKey) {
- String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
- String nonceStr = SignUtils.genRandomStr();
switch (tradeType) {
case JSAPI:
- JsapiResult jsapiResult = new JsapiResult();
- jsapiResult.setAppId(appId).setTimeStamp(timestamp)
- .setPackageValue("prepay_id=" + this.prepayId).setNonceStr(nonceStr)
- //签名类型,默认为RSA,仅支持RSA。
- .setSignType("RSA").setPaySign(SignUtils.sign(jsapiResult.getSignStr(), privateKey));
- return (T) jsapiResult;
+ return (T) buildJsapiResult(this.prepayId, appId, privateKey);
case H5:
return (T) this.h5Url;
case APP:
- AppResult appResult = new AppResult();
- appResult.setAppid(appId).setPrepayId(this.prepayId).setPartnerId(mchId)
- .setNoncestr(nonceStr).setTimestamp(timestamp)
- //暂填写固定值Sign=WXPay
- .setPackageValue("Sign=WXPay")
- .setSign(SignUtils.sign(appResult.getSignStr(), privateKey));
- return (T) appResult;
+ return (T) buildAppResult(this.prepayId, appId, mchId, privateKey);
case NATIVE:
return (T) this.codeUrl;
default:
throw new WxRuntimeException("不支持的支付类型");
}
}
+
+ /**
+ *
+ * 根据已有的prepay_id生成JSAPI支付所需的参数对象(解耦版本)
+ * 应用场景:
+ * 1. 用户已经通过createPartnerOrderV3或unifiedPartnerOrderV3获取了prepay_id
+ * 2. 用户希望存储prepay_id用于后续复用
+ * 3. 支付失败后,使用存储的prepay_id重新生成支付签名信息
+ *
+ * 使用示例:
+ * // 步骤1:创建订单并获取prepay_id
+ * WxPayUnifiedOrderV3Result result = wxPayService.unifiedPartnerOrderV3(TradeTypeEnum.JSAPI, request);
+ * String prepayId = result.getPrepayId();
+ * // 存储prepayId到数据库...
+ *
+ * // 步骤2:需要支付时,使用存储的prepay_id生成支付信息
+ * WxPayUnifiedOrderV3Result.JsapiResult payInfo = WxPayUnifiedOrderV3Result.getJsapiPayInfo(
+ * prepayId, appId, wxPayService.getConfig().getPrivateKey()
+ * );
+ *
+ *
+ * @param prepayId 预支付交易会话标识
+ * @param appId 应用ID
+ * @param privateKey 商户私钥,用于签名
+ * @return JSAPI支付所需的参数对象
+ */
+ public static JsapiResult getJsapiPayInfo(String prepayId, String appId, PrivateKey privateKey) {
+ if (prepayId == null || appId == null || privateKey == null) {
+ throw new IllegalArgumentException("prepayId, appId 和 privateKey 不能为空");
+ }
+ return buildJsapiResult(prepayId, appId, privateKey);
+ }
+
+ /**
+ *
+ * 根据已有的prepay_id生成APP支付所需的参数对象(解耦版本)
+ * 应用场景:
+ * 1. 用户已经通过createPartnerOrderV3或unifiedPartnerOrderV3获取了prepay_id
+ * 2. 用户希望存储prepay_id用于后续复用
+ * 3. 支付失败后,使用存储的prepay_id重新生成支付签名信息
+ *
+ * 使用示例:
+ * // 步骤1:创建订单并获取prepay_id
+ * WxPayUnifiedOrderV3Result result = wxPayService.unifiedPartnerOrderV3(TradeTypeEnum.APP, request);
+ * String prepayId = result.getPrepayId();
+ * // 存储prepayId到数据库...
+ *
+ * // 步骤2:需要支付时,使用存储的prepay_id生成支付信息
+ * WxPayUnifiedOrderV3Result.AppResult payInfo = WxPayUnifiedOrderV3Result.getAppPayInfo(
+ * prepayId, appId, mchId, wxPayService.getConfig().getPrivateKey()
+ * );
+ *
+ *
+ * @param prepayId 预支付交易会话标识
+ * @param appId 应用ID
+ * @param mchId 商户号
+ * @param privateKey 商户私钥,用于签名
+ * @return APP支付所需的参数对象
+ */
+ public static AppResult getAppPayInfo(String prepayId, String appId, String mchId, PrivateKey privateKey) {
+ if (prepayId == null || appId == null || mchId == null || privateKey == null) {
+ throw new IllegalArgumentException("prepayId, appId, mchId 和 privateKey 不能为空");
+ }
+ return buildAppResult(prepayId, appId, mchId, privateKey);
+ }
+
+ /**
+ * 构建JSAPI支付结果对象
+ *
+ * @param prepayId 预支付交易会话标识
+ * @param appId 应用ID
+ * @param privateKey 商户私钥,用于签名
+ * @return JSAPI支付所需的参数对象
+ */
+ private static JsapiResult buildJsapiResult(String prepayId, String appId, PrivateKey privateKey) {
+ String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
+ String nonceStr = SignUtils.genRandomStr();
+ JsapiResult jsapiResult = new JsapiResult();
+ jsapiResult.setAppId(appId).setTimeStamp(timestamp)
+ .setPackageValue("prepay_id=" + prepayId).setNonceStr(nonceStr)
+ .setPrepayId(prepayId)
+ //签名类型,默认为RSA,仅支持RSA。
+ .setSignType("RSA").setPaySign(SignUtils.sign(jsapiResult.getSignStr(), privateKey));
+ return jsapiResult;
+ }
+
+ /**
+ * 构建APP支付结果对象
+ *
+ * @param prepayId 预支付交易会话标识
+ * @param appId 应用ID
+ * @param mchId 商户号
+ * @param privateKey 商户私钥,用于签名
+ * @return APP支付所需的参数对象
+ */
+ private static AppResult buildAppResult(String prepayId, String appId, String mchId, PrivateKey privateKey) {
+ String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
+ String nonceStr = SignUtils.genRandomStr();
+ AppResult appResult = new AppResult();
+ appResult.setAppid(appId).setPrepayId(prepayId).setPartnerId(mchId)
+ .setNoncestr(nonceStr).setTimestamp(timestamp)
+ //暂填写固定值Sign=WXPay
+ .setPackageValue("Sign=WXPay")
+ .setSign(SignUtils.sign(appResult.getSignStr(), privateKey));
+ return appResult;
+ }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxSignQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxSignQueryResult.java
index 808b9d7ddf..af19aec60a 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxSignQueryResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxSignQueryResult.java
@@ -86,7 +86,7 @@ public class WxSignQueryResult extends BaseWxPayResult implements Serializable {
* 协议解约方式
* 非必传
*/
- @XStreamAlias("contract_terminated_mode")
+ @XStreamAlias("contract_termination_mode")
private Integer contractTerminatedMode;
/**
@@ -112,9 +112,9 @@ protected void loadXml(Document d) {
contractDisplayAccount = readXmlString(d, "contract_display_account");
contractState = readXmlInteger(d, "contract_state");
contractSignedTime = readXmlString(d, "contract_signed_time");
- contractExpiredTime = readXmlString(d, "contrace_Expired_time");
+ contractExpiredTime = readXmlString(d, "contract_expired_time");
contractTerminatedTime = readXmlString(d, "contract_terminated_time");
- contractTerminatedMode = readXmlInteger(d, "contract_terminate_mode");
+ contractTerminatedMode = readXmlInteger(d, "contract_termination_mode");
contractTerminationRemark = readXmlString(d, "contract_termination_remark");
openId = readXmlString(d, "openid");
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/BusinessOperationTransferRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/BusinessOperationTransferRequest.java
index 91d9438833..0129798ed9 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/BusinessOperationTransferRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/BusinessOperationTransferRequest.java
@@ -6,8 +6,10 @@
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
import java.io.Serializable;
+import java.util.List;
/**
* 运营工具-商家转账请求参数
@@ -37,11 +39,13 @@ public class BusinessOperationTransferRequest implements Serializable {
private String outBillNo;
/**
- * 运营工具转账场景ID
- * 必须,用于标识运营工具转账的具体业务场景
+ * 转账场景ID
+ * 必须,该笔转账使用的转账场景,可前往"商户平台-产品中心-商家转账"中申请。
+ * 运营工具场景ID如:2001(现金营销)、2002(佣金报酬)、2003(推广奖励)等
+ * 可使用 {@link com.github.binarywang.wxpay.constant.WxPayConstants.OperationSceneId} 中定义的常量
*/
- @SerializedName("operation_scene_id")
- private String operationSceneId;
+ @SerializedName("transfer_scene_id")
+ private String transferSceneId;
/**
* 用户在直连商户应用下的用户标示
@@ -86,4 +90,36 @@ public class BusinessOperationTransferRequest implements Serializable {
*/
@SerializedName("notify_url")
private String notifyUrl;
-}
\ No newline at end of file
+
+ /**
+ * 转账场景报备信息
+ * 必须,需按转账场景准确填写报备信息,参考 转账场景报备信息字段说明
+ */
+ @SerializedName("transfer_scene_report_infos")
+ private List transferSceneReportInfos;
+
+ /**
+ * 转账场景报备信息
+ */
+ @Data
+ @Accessors(chain = true)
+ public static class TransferSceneReportInfo implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 信息类型
+ * 必须,不能超过15个字符,商户所属转账场景下的信息类型,此字段内容为固定值,需严格按照 转账场景报备信息字段说明 传参。
+ */
+ @SerializedName("info_type")
+ private String infoType;
+
+ /**
+ * 信息内容
+ * 必须,不能超过32个字符,商户所属转账场景下的信息内容,商户可按实际业务场景自定义传参,需严格按照 转账场景报备信息字段说明 传参。
+ */
+ @SerializedName("info_content")
+ private String infoContent;
+
+ }
+
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/BusinessOperationTransferResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/BusinessOperationTransferResult.java
index a380d6133e..91771b43e1 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/BusinessOperationTransferResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/BusinessOperationTransferResult.java
@@ -31,15 +31,27 @@ public class BusinessOperationTransferResult implements Serializable {
private String transferBillNo;
/**
- * 转账状态
- * WAIT_PAY:等待确认
- * PROCESSING:转账中
- * SUCCESS:转账成功
- * FAIL:转账失败
- * REFUND:已退款
+ * 单据状态
+ * 商家转账订单状态
+ * ACCEPTED:转账已受理,可原单重试(非终态)。
+ * PROCESSING: 转账锁定资金中。如果一直停留在该状态,建议检查账户余额是否足够,如余额不足,可充值后再原单重试(非终态)。
+ * WAIT_USER_CONFIRM: 待收款用户确认,当前转账单据资金已锁定,可拉起微信收款确认页面进行收款确认(非终态)。
+ * TRANSFERING: 转账中,可拉起微信收款确认页面再次重试确认收款(非终态)。
+ * SUCCESS: 转账成功,表示转账单据已成功(终态)。
+ * FAIL: 转账失败,表示该笔转账单据已失败。若需重新向用户转账,请重新生成单据并再次发起(终态)。
+ * CANCELING: 转账撤销中,商户撤销请求受理成功,该笔转账正在撤销中,需查单确认撤销的转账单据状态(非终态)。
+ * CANCELLED: 转账撤销完成,代表转账单据已撤销成功(终态)。
*/
- @SerializedName("transfer_state")
- private String transferState;
+ @SerializedName("state")
+ private String state;
+
+ /**
+ * 跳转领取页面的package信息
+ * 跳转微信支付收款页的package信息, APP调起用户确认收款 或者 JSAPI调起用户确认收款 时需要使用的参数。仅当转账单据状态为WAIT_USER_CONFIRM时返回。
+ * 单据创建后,用户24小时内不领取将过期关闭,建议拉起用户确认收款页面前,先查单据状态:如单据状态为WAIT_USER_CONFIRM,可用之前的package信息拉起;单据到终态时需更换单号重新发起转账。
+ */
+ @SerializedName("package_info")
+ private String packageInfo;
/**
* 发起转账的时间
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBillsRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBillsRequest.java
index 230e564e4b..2ac4b08c93 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBillsRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBillsRequest.java
@@ -87,6 +87,26 @@ public class TransferBillsRequest implements Serializable {
@SerializedName("transfer_scene_report_infos")
private List transferSceneReportInfos;
+ /**
+ * 收款授权模式
+ *
+ * 字段名:收款授权模式
+ * 变量名:receipt_authorization_mode
+ * 是否必填:否
+ * 类型:string
+ * 描述:
+ * 控制收款方式的授权模式,可选值:
+ * - CONFIRM_RECEIPT_AUTHORIZATION:需确认收款授权模式(默认值)
+ * - NO_CONFIRM_RECEIPT_AUTHORIZATION:免确认收款授权模式(需要用户事先授权)
+ * 为空时,默认为需确认收款授权模式
+ * 示例值:NO_CONFIRM_RECEIPT_AUTHORIZATION
+ *
+ *
+ * @see com.github.binarywang.wxpay.constant.WxPayConstants.ReceiptAuthorizationMode
+ */
+ @SerializedName("receipt_authorization_mode")
+ private String receiptAuthorizationMode;
+
@Data
@Builder(builderMethodName = "newBuilder")
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 f4a1c3d008..88e544e675 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
@@ -97,9 +97,13 @@ public class WxPayConfig {
*/
private String subMchId;
/**
- * 微信支付异步回掉地址,通知url必须为直接可访问的url,不能携带参数.
+ * 微信支付异步回调地址,通知url必须为直接可访问的url,不能携带参数.
*/
private String notifyUrl;
+ /**
+ * 退款结果异步回调地址,通知url必须为直接可访问的url,不能携带参数.
+ */
+ private String refundNotifyUrl;
/**
* 交易类型.
*
@@ -325,7 +329,8 @@ public SSLContext initSSLContext() throws WxPayException {
*
* @return org.apache.http.impl.client.CloseableHttpClient
* @author doger.wang
- **/
+ * @throws WxPayException 微信支付异常
+ */
public CloseableHttpClient initApiV3HttpClient() throws WxPayException {
if (StringUtils.isBlank(this.getApiV3Key())) {
throw new WxPayException("请确保apiV3Key值已设置");
@@ -343,7 +348,7 @@ public CloseableHttpClient initApiV3HttpClient() throws WxPayException {
certificate = (X509Certificate) objects[1];
this.certSerialNo = certificate.getSerialNumber().toString(16).toUpperCase();
}
- if (certificate == null && StringUtils.isBlank(this.getCertSerialNo()) && (StringUtils.isNotBlank(this.getPrivateCertPath()) || StringUtils.isNotBlank(this.getPrivateCertString())) || this.getPrivateCertContent() != null) {
+ if (certificate == null && StringUtils.isBlank(this.getCertSerialNo()) && (StringUtils.isNotBlank(this.getPrivateCertPath()) || StringUtils.isNotBlank(this.getPrivateCertString()) || this.getPrivateCertContent() != null)) {
try (InputStream certInputStream = this.loadConfigInputStream(this.getPrivateCertString(), this.getPrivateCertPath(),
this.privateCertContent, "privateCertPath")) {
certificate = PemUtils.loadCertificate(certInputStream);
@@ -663,6 +668,8 @@ public CloseableHttpClient initSslHttpClient() throws WxPayException {
/**
* 配置HTTP代理
+ *
+ * @param httpClientBuilder HttpClient构建器
*/
private void configureProxy(org.apache.http.impl.client.HttpClientBuilder httpClientBuilder) {
if (StringUtils.isNotBlank(this.getHttpProxyHost()) && this.getHttpProxyPort() > 0) {
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 ec9e14ff2d..2b736691b7 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
@@ -524,4 +524,25 @@ public static class CASH_MARKETING {
}
}
+
+ /**
+ * 收款授权模式
+ *
+ * @see 官方文档
+ */
+ @UtilityClass
+ public static class ReceiptAuthorizationMode {
+ /**
+ * 需确认收款授权模式(默认值)
+ * 用户需要手动确认才能收款
+ */
+ public static final String CONFIRM_RECEIPT_AUTHORIZATION = "CONFIRM_RECEIPT_AUTHORIZATION";
+
+ /**
+ * 免确认收款授权模式
+ * 用户授权后,收款不需要确认,转账直接到账
+ */
+ public static final String NO_CONFIRM_RECEIPT_AUTHORIZATION = "NO_CONFIRM_RECEIPT_AUTHORIZATION";
+ }
+
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/example/BusinessOperationTransferExample.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/example/BusinessOperationTransferExample.java
index d11738816b..117395ba62 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/example/BusinessOperationTransferExample.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/example/BusinessOperationTransferExample.java
@@ -8,6 +8,8 @@
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
+import java.util.Arrays;
+
/**
* 运营工具-商家转账API使用示例
*
@@ -41,10 +43,15 @@ public void init() {
public void createOperationTransferExample() {
try {
// 构建转账请求
+ BusinessOperationTransferRequest.TransferSceneReportInfo reportInfo = new BusinessOperationTransferRequest.TransferSceneReportInfo();
+ reportInfo.setInfoType("活动名称");
+ reportInfo.setInfoContent("新会员有礼");
+
BusinessOperationTransferRequest request = BusinessOperationTransferRequest.newBuilder()
.appid("your_app_id") // 应用ID
.outBillNo("OT" + System.currentTimeMillis()) // 商户转账单号
- .operationSceneId(WxPayConstants.OperationSceneId.OPERATION_CASH_MARKETING) // 运营工具转账场景ID
+ .transferSceneId(WxPayConstants.OperationSceneId.OPERATION_CASH_MARKETING) // 运营工具转账场景ID
+ .transferSceneReportInfos(Arrays.asList(reportInfo)) // 转账场景报备信息
.openid("user_openid") // 用户openid
.userName("张三") // 用户姓名(可选)
.transferAmount(100) // 转账金额,单位分
@@ -59,7 +66,8 @@ public void createOperationTransferExample() {
System.out.println("转账成功!");
System.out.println("商户单号: " + result.getOutBillNo());
System.out.println("微信转账单号: " + result.getTransferBillNo());
- System.out.println("转账状态: " + result.getTransferState());
+ System.out.println("单据状态: " + result.getState());
+ System.out.println("跳转领取页面的package信息: " + result.getPackageInfo());
System.out.println("创建时间: " + result.getCreateTime());
} catch (WxPayException e) {
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/example/NewTransferApiExample.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/example/NewTransferApiExample.java
index 8d74e5a4ef..228234d589 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/example/NewTransferApiExample.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/example/NewTransferApiExample.java
@@ -3,6 +3,7 @@
import com.github.binarywang.wxpay.bean.notify.SignatureHeader;
import com.github.binarywang.wxpay.bean.transfer.*;
import com.github.binarywang.wxpay.config.WxPayConfig;
+import com.github.binarywang.wxpay.constant.WxPayConstants;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.TransferService;
import com.github.binarywang.wxpay.service.WxPayService;
@@ -215,6 +216,100 @@ public void batchTransferExample() {
}
}
+ /**
+ * 使用免确认收款授权模式进行转账示例
+ * 注意:使用此模式前,用户需要先进行授权
+ */
+ public void transferWithNoConfirmAuthModeExample() {
+ try {
+ // 构建转账请求,使用免确认收款授权模式
+ TransferBillsRequest request = TransferBillsRequest.newBuilder()
+ .appid("wx1234567890123456")
+ .outBillNo("NO_CONFIRM_" + System.currentTimeMillis()) // 商户转账单号
+ .transferSceneId("1005") // 转账场景ID(佣金报酬)
+ .openid("oUpF8uMuAJO_M2pxb1Q9zNjWeS6o") // 收款用户的openid
+ .transferAmount(200) // 转账金额,单位:分(此处为2元)
+ .transferRemark("免确认收款转账") // 转账备注
+ .receiptAuthorizationMode(WxPayConstants.ReceiptAuthorizationMode.NO_CONFIRM_RECEIPT_AUTHORIZATION)
+ .userRecvPerception("Y") // 用户收款感知
+ .build();
+
+ // 发起转账
+ TransferBillsResult result = transferService.transferBills(request);
+
+ System.out.println("=== 免确认授权模式转账成功 ===");
+ System.out.println("商户单号: " + result.getOutBillNo());
+ System.out.println("微信转账单号: " + result.getTransferBillNo());
+ System.out.println("状态: " + result.getState());
+ System.out.println("说明: 使用免确认授权模式,转账直接到账,无需用户确认");
+
+ } catch (WxPayException e) {
+ System.err.println("免确认授权转账失败: " + e.getMessage());
+ System.err.println("错误代码: " + e.getErrCode());
+
+ // 可能的错误原因
+ if ("USER_NOT_AUTHORIZED".equals(e.getErrCode())) {
+ System.err.println("用户未授权免确认收款,请先引导用户进行授权");
+ }
+ }
+ }
+
+ /**
+ * 使用需确认收款授权模式进行转账示例(默认模式)
+ */
+ public void transferWithConfirmAuthModeExample() {
+ try {
+ // 构建转账请求,显式设置为需确认收款授权模式
+ TransferBillsRequest request = TransferBillsRequest.newBuilder()
+ .appid("wx1234567890123456")
+ .outBillNo("CONFIRM_" + System.currentTimeMillis()) // 商户转账单号
+ .transferSceneId("1005") // 转账场景ID
+ .openid("oUpF8uMuAJO_M2pxb1Q9zNjWeS6o") // 收款用户的openid
+ .transferAmount(150) // 转账金额,单位:分(此处为1.5元)
+ .transferRemark("需确认收款转账") // 转账备注
+ .receiptAuthorizationMode(WxPayConstants.ReceiptAuthorizationMode.CONFIRM_RECEIPT_AUTHORIZATION)
+ .userRecvPerception("Y") // 用户收款感知
+ .build();
+
+ // 发起转账
+ TransferBillsResult result = transferService.transferBills(request);
+
+ System.out.println("=== 需确认授权模式转账成功 ===");
+ System.out.println("商户单号: " + result.getOutBillNo());
+ System.out.println("微信转账单号: " + result.getTransferBillNo());
+ System.out.println("状态: " + result.getState());
+ System.out.println("packageInfo: " + result.getPackageInfo());
+ System.out.println("说明: 使用需确认授权模式,用户需要手动确认才能收款");
+
+ } catch (WxPayException e) {
+ System.err.println("需确认授权转账失败: " + e.getMessage());
+ }
+ }
+
+ /**
+ * 权限模式对比示例
+ * 展示两种权限模式的区别和使用场景
+ */
+ public void authModeComparisonExample() {
+ System.out.println("\n=== 收款授权模式对比 ===");
+ System.out.println("1. 需确认收款授权模式 (CONFIRM_RECEIPT_AUTHORIZATION):");
+ System.out.println(" - 这是默认模式");
+ System.out.println(" - 用户收到转账后需要手动点击确认才能到账");
+ System.out.println(" - 适用于一般的转账场景");
+ System.out.println(" - 转账状态可能包含 WAIT_USER_CONFIRM 等待确认状态");
+
+ System.out.println("\n2. 免确认收款授权模式 (NO_CONFIRM_RECEIPT_AUTHORIZATION):");
+ System.out.println(" - 用户事先授权后,转账直接到账,无需确认");
+ System.out.println(" - 提升用户体验,减少操作步骤");
+ System.out.println(" - 适用于高频转账场景,如佣金发放等");
+ System.out.println(" - 需要用户先进行授权,否则会返回授权错误");
+
+ System.out.println("\n使用建议:");
+ System.out.println("- 高频业务场景推荐使用免确认模式,提升用户体验");
+ System.out.println("- 首次使用需引导用户进行授权");
+ System.out.println("- 处理授权相关异常,提供友好的错误提示");
+ }
+
/**
* 使用配置示例
*/
@@ -230,20 +325,29 @@ public static void main(String[] args) {
// 创建示例实例
NewTransferApiExample example = new NewTransferApiExample(config);
+ // 权限模式对比说明
+ example.authModeComparisonExample();
+
// 运行示例
System.out.println("新版商户转账API使用示例");
System.out.println("===============================");
- // 1. 发起单笔转账
+ // 1. 发起转账(使用免确认授权模式)
+ // example.transferWithNoConfirmAuthModeExample();
+
+ // 2. 发起转账(使用需确认授权模式)
+ // example.transferWithConfirmAuthModeExample();
+
+ // 3. 发起单笔转账(默认模式)
example.transferExample();
- // 2. 查询转账结果
+ // 4. 查询转账结果
// example.queryByOutBillNoExample();
- // 3. 撤销转账
+ // 5. 撤销转账
// example.cancelTransferExample();
- // 4. 批量转账(传统API)
+ // 6. 批量转账(传统API)
// example.batchTransferExample();
}
}
\ No newline at end of file
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/BusinessOperationTransferService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/BusinessOperationTransferService.java
index 740c2af83f..195d3a8409 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/BusinessOperationTransferService.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/BusinessOperationTransferService.java
@@ -21,7 +21,7 @@ public interface BusinessOperationTransferService {
* 发起运营工具商家转账
*
* 请求方式:POST(HTTPS)
- * 请求地址:https://api.mch.weixin.qq.com/v3/fund-app/operation/mch-transfer/transfer-bills
+ * 请求地址:https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/transfer-bills
*
* 文档地址:运营工具-商家转账API
*
@@ -37,7 +37,7 @@ public interface BusinessOperationTransferService {
* 查询运营工具转账结果
*
* 请求方式:GET(HTTPS)
- * 请求地址:https://api.mch.weixin.qq.com/v3/fund-app/operation/mch-transfer/transfer-bills/out-bill-no/{out_bill_no}
+ * 请求地址:https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/transfer-bills/out-bill-no/{out_bill_no}
*
* 文档地址:运营工具-商家转账API
*
@@ -53,7 +53,7 @@ public interface BusinessOperationTransferService {
* 通过商户单号查询运营工具转账结果
*
* 请求方式:GET(HTTPS)
- * 请求地址:https://api.mch.weixin.qq.com/v3/fund-app/operation/mch-transfer/transfer-bills/out-bill-no/{out_bill_no}
+ * 请求地址:https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/transfer-bills/out-bill-no/{out_bill_no}
*
* 文档地址:运营工具-商家转账API
*
@@ -69,7 +69,7 @@ public interface BusinessOperationTransferService {
* 通过微信转账单号查询运营工具转账结果
*
* 请求方式:GET(HTTPS)
- * 请求地址:https://api.mch.weixin.qq.com/v3/fund-app/operation/mch-transfer/transfer-bills/transfer-bill-no/{transfer_bill_no}
+ * 请求地址:https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/transfer-bills/transfer-bill-no/{transfer_bill_no}
*
* 文档地址:运营工具-商家转账API
*
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MiPayService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MiPayService.java
new file mode 100644
index 0000000000..5e2f678c16
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MiPayService.java
@@ -0,0 +1,95 @@
+package com.github.binarywang.wxpay.service;
+
+import com.github.binarywang.wxpay.bean.mipay.MedInsOrdersRequest;
+import com.github.binarywang.wxpay.bean.mipay.MedInsOrdersResult;
+import com.github.binarywang.wxpay.bean.mipay.MedInsRefundNotifyRequest;
+import com.github.binarywang.wxpay.bean.notify.MiPayNotifyV3Result;
+import com.github.binarywang.wxpay.bean.notify.SignatureHeader;
+import com.github.binarywang.wxpay.exception.WxPayException;
+
+/**
+ * 医保相关接口
+ * 医保相关接口
+ * @author xgl
+ * @date 2025/12/20
+ */
+public interface MiPayService {
+
+ /**
+ * + * 医保自费混合收款下单 + * + * 从业机构调用该接口向微信医保后台下单 + * + * 文档地址:医保自费混合收款下单 + *+ * + * @param request 下单参数 + * @return ReservationTransferNotifyResult 下单结果 + * @throws WxPayException the wx pay exception + */ + MedInsOrdersResult medInsOrders(MedInsOrdersRequest request) throws WxPayException; + + /** + *
+ * 使用医保自费混合订单号查看下单结果 + * + * 从业机构使用混合下单订单号,通过该接口主动查询订单状态,完成下一步的业务逻辑。 + * + * 文档地址:使用医保自费混合订单号查看下单结果 + *+ * + * @param mixTradeNo 医保自费混合订单号 + * @param subMchid 医疗机构的商户号 + * @return MedInsOrdersResult 下单结果 + * @throws WxPayException the wx pay exception + */ + MedInsOrdersResult getMedInsOrderByMixTradeNo(String mixTradeNo, String subMchid) throws WxPayException; + + /** + *
+ * 使用从业机构订单号查看下单结果 + * + * 从业机构使用从业机构订单号、医疗机构商户号,通过该接口主动查询订单状态,完成下一步的业务逻辑。 + * + * 文档地址:使用从业机构订单号查看下单结果 + *+ * + * @param outTradeNo 从业机构订单号 + * @param subMchid 医疗机构的商户号 + * @return MedInsOrdersResult 下单结果 + * @throws WxPayException the wx pay exception + */ + MedInsOrdersResult getMedInsOrderByOutTradeNo(String outTradeNo, String subMchid) throws WxPayException; + + /** + *
+ * 解析医保混合收款成功通知 + * + * 微信支付会通过POST请求向商户设置的回调URL推送医保混合收款成功通知,商户需要接收处理该消息,并返回应答。 + * + * 文档地址:医保混合收款成功通知 + *+ * + * @param notifyData 通知数据字符串 + * @return MiPayNotifyV3Result 医保混合收款成功通知结果 + * @throws WxPayException the wx pay exception + */ + MiPayNotifyV3Result parseMiPayNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException; + + /** + *
+ * 医保退款通知 + * + * 从业机构调用该接口向微信医保后台通知医保订单的退款成功结果 + * + * 文档地址:医保退款通知 + *+ * + * @param request 医保退款通知请求参数 + * @param mixTradeNo 【医保自费混合订单号】 医保自费混合订单号 + * @throws WxPayException the wx pay exception + */ + void medInsRefundNotify(MedInsRefundNotifyRequest request, String mixTradeNo) throws WxPayException; + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/RealNameService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/RealNameService.java new file mode 100644 index 0000000000..d69bda7d33 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/RealNameService.java @@ -0,0 +1,43 @@ +package com.github.binarywang.wxpay.service; + +import com.github.binarywang.wxpay.bean.realname.RealNameRequest; +import com.github.binarywang.wxpay.bean.realname.RealNameResult; +import com.github.binarywang.wxpay.exception.WxPayException; + +/** + *
+ * 微信支付实名验证相关服务类. + * 详见文档:https://pay.wechatpay.cn/doc/v2/merchant/4011987607 + *+ * + * @author Binary Wang + */ +public interface RealNameService { + /** + *
+ * 获取用户实名认证信息API. + * 用于商户查询用户的实名认证状态,如果用户未实名认证,会返回引导用户实名认证的URL + * 文档详见:https://pay.wechatpay.cn/doc/v2/merchant/4011987607 + * 接口链接:https://api.mch.weixin.qq.com/userinfo/realnameauth/query + *+ * + * @param request 请求对象 + * @return 实名认证查询结果 + * @throws WxPayException the wx pay exception + */ + RealNameResult queryRealName(RealNameRequest request) throws WxPayException; + + /** + *
+ * 获取用户实名认证信息API(简化方法). + * 用于商户查询用户的实名认证状态,如果用户未实名认证,会返回引导用户实名认证的URL + * 文档详见:https://pay.wechatpay.cn/doc/v2/merchant/4011987607 + * 接口链接:https://api.mch.weixin.qq.com/userinfo/realnameauth/query + *+ * + * @param openid 用户openid + * @return 实名认证查询结果 + * @throws WxPayException the wx pay exception + */ + RealNameResult queryRealName(String openid) throws WxPayException; +} 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 93da0d1332..dab89a0142 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 @@ -1706,4 +1706,19 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri * @return the partner pay score sign plan service */ PartnerPayScoreSignPlanService getPartnerPayScoreSignPlanService(); + + /** + * 获取实名验证服务类 + * + * @return the real name service + */ + RealNameService getRealNameService(); + + /** + * 获取医保支付服务类 + * + * @return the merchant transfer service + */ + MiPayService getMiPayService(); + } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java index ba3dc37144..5347099a0b 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java @@ -1,17 +1,21 @@ package com.github.binarywang.wxpay.service.impl; -import com.github.binarywang.utils.qrcode.QrcodeUtils; -import com.github.binarywang.wxpay.bean.WxPayApiData; +import static com.github.binarywang.wxpay.constant.WxPayConstants.QUERY_COMMENT_DATE_FORMAT; +import static com.github.binarywang.wxpay.constant.WxPayConstants.TarType; import com.github.binarywang.wxpay.bean.coupon.*; import com.github.binarywang.wxpay.bean.notify.*; +import com.github.binarywang.wxpay.bean.request.*; +import com.github.binarywang.wxpay.bean.result.*; +import com.github.binarywang.wxpay.service.*; +import java.util.*; +import com.github.binarywang.wxpay.bean.result.enums.GlobalTradeTypeEnum; +import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; +import com.github.binarywang.utils.qrcode.QrcodeUtils; +import com.github.binarywang.wxpay.bean.WxPayApiData; import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult; import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult; 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.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.bean.result.enums.GlobalTradeTypeEnum; import com.github.binarywang.wxpay.bean.transfer.TransferBillsNotifyResult; import com.github.binarywang.wxpay.config.WxPayConfig; import com.github.binarywang.wxpay.config.WxPayConfigHolder; @@ -19,7 +23,6 @@ import com.github.binarywang.wxpay.constant.WxPayConstants.TradeType; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.exception.WxSignTestException; -import com.github.binarywang.wxpay.service.*; import com.github.binarywang.wxpay.util.SignUtils; import com.github.binarywang.wxpay.util.XmlConfig; import com.github.binarywang.wxpay.util.ZipUtils; @@ -29,14 +32,6 @@ import com.google.common.collect.Maps; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import lombok.Getter; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.error.WxRuntimeException; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.reflect.ConstructorUtils; -import org.apache.http.entity.ContentType; - import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -45,12 +40,15 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.security.GeneralSecurityException; -import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.zip.ZipException; - -import static com.github.binarywang.wxpay.constant.WxPayConstants.QUERY_COMMENT_DATE_FORMAT; -import static com.github.binarywang.wxpay.constant.WxPayConstants.TarType; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxRuntimeException; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.reflect.ConstructorUtils; +import org.apache.http.entity.ContentType; /** *
@@ -139,6 +137,12 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
@Getter
private final BusinessOperationTransferService businessOperationTransferService = new BusinessOperationTransferServiceImpl(this);
+ @Getter
+ private final RealNameService realNameService = new RealNameServiceImpl(this);
+
+ @Getter
+ private final MiPayService miPayService = new MiPayServiceImpl(this);
+
protected Map configMap = new ConcurrentHashMap<>();
@Override
@@ -259,6 +263,9 @@ public WxPayRefundResult refundV2(WxPayRefundRequest request) throws WxPayExcept
@Override
public WxPayRefundV3Result refundV3(WxPayRefundV3Request request) throws WxPayException {
+ if (StringUtils.isBlank(request.getNotifyUrl())) {
+ request.setNotifyUrl(this.getConfig().getRefundNotifyUrl());
+ }
String url = String.format("%s/v3/refund/domestic/refunds", this.getPayBaseUrl());
String response = this.postV3WithWechatpaySerial(url, GSON.toJson(request));
return GSON.fromJson(response, WxPayRefundV3Result.class);
@@ -266,6 +273,9 @@ public WxPayRefundV3Result refundV3(WxPayRefundV3Request request) throws WxPayEx
@Override
public WxPayRefundV3Result partnerRefundV3(WxPayPartnerRefundV3Request request) throws WxPayException {
+ if (StringUtils.isBlank(request.getNotifyUrl())) {
+ request.setNotifyUrl(this.getConfig().getRefundNotifyUrl());
+ }
if (StringUtils.isBlank(request.getSubMchid())) {
request.setSubMchid(this.getConfig().getSubMchId());
}
@@ -340,6 +350,13 @@ public WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData) throws WxPa
public WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData, String signType) throws WxPayException {
try {
log.debug("微信支付异步通知请求参数:{}", xmlData);
+
+ // 检测数据格式并给出适当的处理建议
+ if (xmlData != null && xmlData.trim().startsWith("{")) {
+ throw new WxPayException("检测到V3版本的JSON格式通知数据,请使用parseOrderNotifyV3Result方法解析。" +
+ " V3 API需要传入SignatureHeader参数进行签名验证。");
+ }
+
WxPayOrderNotifyResult result = WxPayOrderNotifyResult.fromXML(xmlData);
if (signType == null) {
this.switchover(result.getMchId(), result.getAppid());
@@ -1197,15 +1214,40 @@ public WxPayMicropayResult micropay(WxPayMicropayRequest request) throws WxPayEx
@Override
public WxPayCodepayResult codepay(WxPayCodepayRequest request) throws WxPayException {
- if (StringUtils.isBlank(request.getAppid())) {
- request.setAppid(this.getConfig().getAppId());
- }
- if (StringUtils.isBlank(request.getMchid())) {
- request.setMchid(this.getConfig().getMchId());
+ // 判断是否为服务商模式:如果设置了sp_appid或sp_mchid或sub_mchid中的任何一个,则认为是服务商模式
+ boolean isPartnerMode = StringUtils.isNotBlank(request.getSpAppid())
+ || StringUtils.isNotBlank(request.getSpMchid())
+ || StringUtils.isNotBlank(request.getSubMchid());
+
+ if (isPartnerMode) {
+ // 服务商模式
+ if (StringUtils.isBlank(request.getSpAppid())) {
+ request.setSpAppid(this.getConfig().getAppId());
+ }
+ if (StringUtils.isBlank(request.getSpMchid())) {
+ request.setSpMchid(this.getConfig().getMchId());
+ }
+ if (StringUtils.isBlank(request.getSubAppid())) {
+ request.setSubAppid(this.getConfig().getSubAppId());
+ }
+ if (StringUtils.isBlank(request.getSubMchid())) {
+ request.setSubMchid(this.getConfig().getSubMchId());
+ }
+ String url = String.format("%s/v3/pay/partner/transactions/codepay", this.getPayBaseUrl());
+ String body = this.postV3WithWechatpaySerial(url, GSON.toJson(request));
+ return GSON.fromJson(body, WxPayCodepayResult.class);
+ } else {
+ // 直连商户模式
+ if (StringUtils.isBlank(request.getAppid())) {
+ request.setAppid(this.getConfig().getAppId());
+ }
+ if (StringUtils.isBlank(request.getMchid())) {
+ request.setMchid(this.getConfig().getMchId());
+ }
+ String url = String.format("%s/v3/pay/transactions/codepay", this.getPayBaseUrl());
+ String body = this.postV3WithWechatpaySerial(url, GSON.toJson(request));
+ return GSON.fromJson(body, WxPayCodepayResult.class);
}
- String url = String.format("%s/v3/pay/transactions/codepay", this.getPayBaseUrl());
- String body = this.postV3WithWechatpaySerial(url, GSON.toJson(request));
- return GSON.fromJson(body, WxPayCodepayResult.class);
}
@Override
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BusinessOperationTransferServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BusinessOperationTransferServiceImpl.java
index 5e74bdbaab..098db127e3 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BusinessOperationTransferServiceImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BusinessOperationTransferServiceImpl.java
@@ -33,7 +33,7 @@ public BusinessOperationTransferResult createOperationTransfer(BusinessOperation
request.setAppid(this.wxPayService.getConfig().getAppId());
}
- String url = String.format("%s/v3/fund-app/operation/mch-transfer/transfer-bills", this.wxPayService.getPayBaseUrl());
+ String url = String.format("%s/v3/fund-app/mch-transfer/transfer-bills", this.wxPayService.getPayBaseUrl());
// 如果传入了用户姓名,需要进行RSA加密
if (StringUtils.isNotEmpty(request.getUserName())) {
@@ -58,7 +58,7 @@ public BusinessOperationTransferQueryResult queryOperationTransfer(BusinessOpera
@Override
public BusinessOperationTransferQueryResult queryOperationTransferByOutBillNo(String outBillNo) throws WxPayException {
- String url = String.format("%s/v3/fund-app/operation/mch-transfer/transfer-bills/out-bill-no/%s",
+ String url = String.format("%s/v3/fund-app/mch-transfer/transfer-bills/out-bill-no/%s",
this.wxPayService.getPayBaseUrl(), outBillNo);
String response = wxPayService.getV3(url);
return GSON.fromJson(response, BusinessOperationTransferQueryResult.class);
@@ -66,7 +66,7 @@ public BusinessOperationTransferQueryResult queryOperationTransferByOutBillNo(St
@Override
public BusinessOperationTransferQueryResult queryOperationTransferByTransferBillNo(String transferBillNo) throws WxPayException {
- String url = String.format("%s/v3/fund-app/operation/mch-transfer/transfer-bills/transfer-bill-no/%s",
+ String url = String.format("%s/v3/fund-app/mch-transfer/transfer-bills/transfer-bill-no/%s",
this.wxPayService.getPayBaseUrl(), transferBillNo);
String response = wxPayService.getV3(url);
return GSON.fromJson(response, BusinessOperationTransferQueryResult.class);
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MiPayServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MiPayServiceImpl.java
new file mode 100644
index 0000000000..769b789fa3
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MiPayServiceImpl.java
@@ -0,0 +1,68 @@
+package com.github.binarywang.wxpay.service.impl;
+
+import com.github.binarywang.wxpay.bean.mipay.MedInsOrdersRequest;
+import com.github.binarywang.wxpay.bean.mipay.MedInsOrdersResult;
+import com.github.binarywang.wxpay.bean.mipay.MedInsRefundNotifyRequest;
+import com.github.binarywang.wxpay.bean.notify.MiPayNotifyV3Result;
+import com.github.binarywang.wxpay.bean.notify.SignatureHeader;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import com.github.binarywang.wxpay.service.MiPayService;
+import com.github.binarywang.wxpay.service.WxPayService;
+import com.github.binarywang.wxpay.v3.util.RsaCryptoUtil;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import java.security.cert.X509Certificate;
+import lombok.RequiredArgsConstructor;
+
+/**
+ * 医保相关接口
+ * 医保相关接口
+ * @author xgl
+ * @date 2025/12/20
+ */
+@RequiredArgsConstructor
+public class MiPayServiceImpl implements MiPayService {
+
+ private final WxPayService payService;
+ private static final Gson GSON = new GsonBuilder().create();
+
+
+ @Override
+ public MedInsOrdersResult medInsOrders(MedInsOrdersRequest request) throws WxPayException {
+
+ String url = String.format("%s/v3/med-ins/orders", this.payService.getPayBaseUrl());
+ X509Certificate validCertificate = this.payService.getConfig().getVerifier().getValidCertificate();
+
+ RsaCryptoUtil.encryptFields(request, validCertificate);
+
+ String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request));
+ return GSON.fromJson(result, MedInsOrdersResult.class);
+ }
+
+ @Override
+ public MedInsOrdersResult getMedInsOrderByMixTradeNo(String mixTradeNo, String subMchid) throws WxPayException {
+ String url = String.format("%s/v3/med-ins/orders/mix-trade-no/%s?sub_mchid=%s", this.payService.getPayBaseUrl(), mixTradeNo, subMchid);
+ String result = this.payService.getV3(url);
+ return GSON.fromJson(result, MedInsOrdersResult.class);
+ }
+
+ @Override
+ public MedInsOrdersResult getMedInsOrderByOutTradeNo(String outTradeNo, String subMchid) throws WxPayException {
+ String url = String.format("%s/v3/med-ins/orders/out-trade-no/%s?sub_mchid=%s", this.payService.getPayBaseUrl(), outTradeNo, subMchid);
+ String result = this.payService.getV3(url);
+ return GSON.fromJson(result, MedInsOrdersResult.class);
+ }
+
+ @Override
+ public MiPayNotifyV3Result parseMiPayNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException {
+ return this.payService.baseParseOrderNotifyV3Result(notifyData, header, MiPayNotifyV3Result.class, MiPayNotifyV3Result.DecryptNotifyResult.class);
+ }
+
+ @Override
+ public void medInsRefundNotify(MedInsRefundNotifyRequest request, String mixTradeNo) throws WxPayException {
+ String url = String.format("%s/v3/med-ins/refunds/notify?mix_trade_no=%s", this.payService.getPayBaseUrl(), mixTradeNo);
+ this.payService.postV3(url, GSON.toJson(request));
+ }
+
+
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/RealNameServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/RealNameServiceImpl.java
new file mode 100644
index 0000000000..9a1c57fe0f
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/RealNameServiceImpl.java
@@ -0,0 +1,41 @@
+package com.github.binarywang.wxpay.service.impl;
+
+import com.github.binarywang.wxpay.bean.realname.RealNameRequest;
+import com.github.binarywang.wxpay.bean.realname.RealNameResult;
+import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import com.github.binarywang.wxpay.service.RealNameService;
+import com.github.binarywang.wxpay.service.WxPayService;
+import lombok.RequiredArgsConstructor;
+
+/**
+ *
+ * 微信支付实名验证相关服务实现类.
+ * 详见文档:https://pay.wechatpay.cn/doc/v2/merchant/4011987607
+ *
+ *
+ * @author Binary Wang
+ */
+@RequiredArgsConstructor
+public class RealNameServiceImpl implements RealNameService {
+ private final WxPayService payService;
+
+ @Override
+ public RealNameResult queryRealName(RealNameRequest request) throws WxPayException {
+ request.checkAndSign(this.payService.getConfig());
+ String url = this.payService.getPayBaseUrl() + "/userinfo/realnameauth/query";
+
+ String responseContent = this.payService.post(url, request.toXML(), true);
+ RealNameResult result = BaseWxPayResult.fromXML(responseContent, RealNameResult.class);
+ result.checkResult(this.payService, request.getSignType(), true);
+ return result;
+ }
+
+ @Override
+ public RealNameResult queryRealName(String openid) throws WxPayException {
+ RealNameRequest request = RealNameRequest.newBuilder()
+ .openid(openid)
+ .build();
+ return this.queryRealName(request);
+ }
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java
index 8e795966f4..4316bafa40 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java
@@ -2,11 +2,11 @@
/**
*
- * 微信支付接口请求实现类,默认使用Apache HttpClient实现
+ * 微信支付接口请求实现类,默认使用Apache HttpClient 5实现
* Created by Binary Wang on 2017-7-8.
*
*
* @author Binary Wang
*/
-public class WxPayServiceImpl extends WxPayServiceApacheHttpImpl {
+public class WxPayServiceImpl extends WxPayServiceHttpComponentsImpl {
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/RequestUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/RequestUtils.java
index b641cbe537..c4ad966415 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/RequestUtils.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/RequestUtils.java
@@ -17,7 +17,7 @@ public class RequestUtils {
/**
* 获取请求头数据,微信V3版本回调使用
*
- * @param request
+ * @param request HTTP请求对象
* @return 字符串
*/
public static String readData(HttpServletRequest request) {
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/ResourcesUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/ResourcesUtils.java
index ac68b00bb4..51dd8fbbb6 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/ResourcesUtils.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/ResourcesUtils.java
@@ -23,6 +23,10 @@ public class ResourcesUtils {
* - {@link Class#getClassLoader() ClassLoaderUtil.class.getClassLoader()}
* - if
callingClass is provided: {@link Class#getClassLoader() callingClass.getClassLoader()}
* + * WxPayUnifiedOrderV3Result 测试类 + * 主要测试prepayId字段和静态工厂方法的解耦功能 + *+ * + * @author copilot + */ +public class WxPayUnifiedOrderV3ResultTest { + + /** + * 生成测试用的RSA密钥对 + */ + private KeyPair generateKeyPair() throws Exception { + KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); + keyPairGenerator.initialize(2048); + return keyPairGenerator.generateKeyPair(); + } + + /** + * 测试JsapiResult中的prepayId字段是否正确设置 + */ + @Test + public void testJsapiResultWithPrepayId() throws Exception { + // 准备测试数据 + String testPrepayId = "wx201410272009395522657a690389285100"; + String testAppId = "wx8888888888888888"; + KeyPair keyPair = generateKeyPair(); + PrivateKey privateKey = keyPair.getPrivate(); + + // 创建WxPayUnifiedOrderV3Result对象 + WxPayUnifiedOrderV3Result result = new WxPayUnifiedOrderV3Result(); + result.setPrepayId(testPrepayId); + + // 调用getPayInfo生成JsapiResult + WxPayUnifiedOrderV3Result.JsapiResult jsapiResult = + result.getPayInfo(TradeTypeEnum.JSAPI, testAppId, null, privateKey); + + // 验证prepayId字段是否正确设置 + Assert.assertNotNull(jsapiResult.getPrepayId(), "prepayId不应为null"); + Assert.assertEquals(jsapiResult.getPrepayId(), testPrepayId, "prepayId应该与设置的值相同"); + + // 验证其他字段 + Assert.assertEquals(jsapiResult.getAppId(), testAppId); + Assert.assertNotNull(jsapiResult.getTimeStamp()); + Assert.assertNotNull(jsapiResult.getNonceStr()); + Assert.assertEquals(jsapiResult.getPackageValue(), "prepay_id=" + testPrepayId); + Assert.assertEquals(jsapiResult.getSignType(), "RSA"); + Assert.assertNotNull(jsapiResult.getPaySign()); + } + + /** + * 测试使用静态工厂方法生成JsapiResult(解耦场景) + */ + @Test + public void testGetJsapiPayInfoStaticMethod() throws Exception { + // 准备测试数据 + String testPrepayId = "wx201410272009395522657a690389285100"; + String testAppId = "wx8888888888888888"; + KeyPair keyPair = generateKeyPair(); + PrivateKey privateKey = keyPair.getPrivate(); + + // 使用静态工厂方法生成JsapiResult + WxPayUnifiedOrderV3Result.JsapiResult jsapiResult = + WxPayUnifiedOrderV3Result.getJsapiPayInfo(testPrepayId, testAppId, privateKey); + + // 验证prepayId字段 + Assert.assertNotNull(jsapiResult.getPrepayId(), "prepayId不应为null"); + Assert.assertEquals(jsapiResult.getPrepayId(), testPrepayId, "prepayId应该与输入的值相同"); + + // 验证其他字段 + Assert.assertEquals(jsapiResult.getAppId(), testAppId); + Assert.assertNotNull(jsapiResult.getTimeStamp()); + Assert.assertNotNull(jsapiResult.getNonceStr()); + Assert.assertEquals(jsapiResult.getPackageValue(), "prepay_id=" + testPrepayId); + Assert.assertEquals(jsapiResult.getSignType(), "RSA"); + Assert.assertNotNull(jsapiResult.getPaySign()); + } + + /** + * 测试使用静态工厂方法生成AppResult(解耦场景) + */ + @Test + public void testGetAppPayInfoStaticMethod() throws Exception { + // 准备测试数据 + String testPrepayId = "wx201410272009395522657a690389285100"; + String testAppId = "wx8888888888888888"; + String testMchId = "1900000109"; + KeyPair keyPair = generateKeyPair(); + PrivateKey privateKey = keyPair.getPrivate(); + + // 使用静态工厂方法生成AppResult + WxPayUnifiedOrderV3Result.AppResult appResult = + WxPayUnifiedOrderV3Result.getAppPayInfo(testPrepayId, testAppId, testMchId, privateKey); + + // 验证prepayId字段 + Assert.assertNotNull(appResult.getPrepayId(), "prepayId不应为null"); + Assert.assertEquals(appResult.getPrepayId(), testPrepayId, "prepayId应该与输入的值相同"); + + // 验证其他字段 + Assert.assertEquals(appResult.getAppid(), testAppId); + Assert.assertEquals(appResult.getPartnerId(), testMchId); + Assert.assertNotNull(appResult.getTimestamp()); + Assert.assertNotNull(appResult.getNoncestr()); + Assert.assertEquals(appResult.getPackageValue(), "Sign=WXPay"); + Assert.assertNotNull(appResult.getSign()); + } + + /** + * 测试解耦场景:先获取prepayId,后续再生成支付信息 + */ + @Test + public void testDecoupledScenario() throws Exception { + // 模拟场景:先创建订单获取prepayId + String testPrepayId = "wx201410272009395522657a690389285100"; + String testAppId = "wx8888888888888888"; + KeyPair keyPair = generateKeyPair(); + PrivateKey privateKey = keyPair.getPrivate(); + + // 步骤1:模拟从创建订单接口获取prepayId + WxPayUnifiedOrderV3Result orderResult = new WxPayUnifiedOrderV3Result(); + orderResult.setPrepayId(testPrepayId); + + // 获取prepayId用于存储 + String storedPrepayId = orderResult.getPrepayId(); + Assert.assertEquals(storedPrepayId, testPrepayId); + + // 步骤2:后续支付失败时,使用存储的prepayId重新生成支付信息 + WxPayUnifiedOrderV3Result.JsapiResult newPayInfo = + WxPayUnifiedOrderV3Result.getJsapiPayInfo(storedPrepayId, testAppId, privateKey); + + // 验证重新生成的支付信息 + Assert.assertEquals(newPayInfo.getPrepayId(), storedPrepayId); + Assert.assertEquals(newPayInfo.getPackageValue(), "prepay_id=" + storedPrepayId); + Assert.assertNotNull(newPayInfo.getPaySign()); + } + + /** + * 测试多次生成支付信息,签名应该不同(因为timestamp和nonceStr每次都不同) + */ + @Test + public void testMultipleGenerationsHaveDifferentSignatures() throws Exception { + String testPrepayId = "wx201410272009395522657a690389285100"; + String testAppId = "wx8888888888888888"; + KeyPair keyPair = generateKeyPair(); + PrivateKey privateKey = keyPair.getPrivate(); + + // 生成第一次支付信息 + WxPayUnifiedOrderV3Result.JsapiResult result1 = + WxPayUnifiedOrderV3Result.getJsapiPayInfo(testPrepayId, testAppId, privateKey); + + // 等待一秒确保timestamp不同 + Thread.sleep(1000); + + // 生成第二次支付信息 + WxPayUnifiedOrderV3Result.JsapiResult result2 = + WxPayUnifiedOrderV3Result.getJsapiPayInfo(testPrepayId, testAppId, privateKey); + + // prepayId应该相同 + Assert.assertEquals(result1.getPrepayId(), result2.getPrepayId()); + + // 但是timestamp、nonceStr和签名应该不同 + Assert.assertNotEquals(result1.getTimeStamp(), result2.getTimeStamp(), "timestamp应该不同"); + Assert.assertNotEquals(result1.getNonceStr(), result2.getNonceStr(), "nonceStr应该不同"); + Assert.assertNotEquals(result1.getPaySign(), result2.getPaySign(), "签名应该不同"); + } + + /** + * 测试AppResult中的prepayId字段 + */ + @Test + public void testAppResultWithPrepayId() throws Exception { + String testPrepayId = "wx201410272009395522657a690389285100"; + String testAppId = "wx8888888888888888"; + String testMchId = "1900000109"; + KeyPair keyPair = generateKeyPair(); + PrivateKey privateKey = keyPair.getPrivate(); + + WxPayUnifiedOrderV3Result result = new WxPayUnifiedOrderV3Result(); + result.setPrepayId(testPrepayId); + + // 调用getPayInfo生成AppResult + WxPayUnifiedOrderV3Result.AppResult appResult = + result.getPayInfo(TradeTypeEnum.APP, testAppId, testMchId, privateKey); + + // 验证prepayId字段 + Assert.assertNotNull(appResult.getPrepayId(), "prepayId不应为null"); + Assert.assertEquals(appResult.getPrepayId(), testPrepayId, "prepayId应该与设置的值相同"); + } + + /** + * 测试getJsapiPayInfo方法的空值验证 + */ + @Test(expectedExceptions = IllegalArgumentException.class, + expectedExceptionsMessageRegExp = "prepayId, appId 和 privateKey 不能为空") + public void testGetJsapiPayInfoWithNullPrepayId() { + WxPayUnifiedOrderV3Result.getJsapiPayInfo(null, "appId", null); + } + + /** + * 测试getJsapiPayInfo方法的空值验证 - appId为null + */ + @Test(expectedExceptions = IllegalArgumentException.class, + expectedExceptionsMessageRegExp = "prepayId, appId 和 privateKey 不能为空") + public void testGetJsapiPayInfoWithNullAppId() throws Exception { + KeyPair keyPair = generateKeyPair(); + WxPayUnifiedOrderV3Result.getJsapiPayInfo("prepayId", null, keyPair.getPrivate()); + } + + /** + * 测试getJsapiPayInfo方法的空值验证 - privateKey为null + */ + @Test(expectedExceptions = IllegalArgumentException.class, + expectedExceptionsMessageRegExp = "prepayId, appId 和 privateKey 不能为空") + public void testGetJsapiPayInfoWithNullPrivateKey() { + WxPayUnifiedOrderV3Result.getJsapiPayInfo("prepayId", "appId", null); + } + + /** + * 测试getAppPayInfo方法的空值验证 - prepayId为null + */ + @Test(expectedExceptions = IllegalArgumentException.class, + expectedExceptionsMessageRegExp = "prepayId, appId, mchId 和 privateKey 不能为空") + public void testGetAppPayInfoWithNullPrepayId() { + WxPayUnifiedOrderV3Result.getAppPayInfo(null, "appId", "mchId", null); + } + + /** + * 测试getAppPayInfo方法的空值验证 - appId为null + */ + @Test(expectedExceptions = IllegalArgumentException.class, + expectedExceptionsMessageRegExp = "prepayId, appId, mchId 和 privateKey 不能为空") + public void testGetAppPayInfoWithNullAppId() throws Exception { + KeyPair keyPair = generateKeyPair(); + WxPayUnifiedOrderV3Result.getAppPayInfo("prepayId", null, "mchId", keyPair.getPrivate()); + } + + /** + * 测试getAppPayInfo方法的空值验证 - mchId为null + */ + @Test(expectedExceptions = IllegalArgumentException.class, + expectedExceptionsMessageRegExp = "prepayId, appId, mchId 和 privateKey 不能为空") + public void testGetAppPayInfoWithNullMchId() throws Exception { + KeyPair keyPair = generateKeyPair(); + WxPayUnifiedOrderV3Result.getAppPayInfo("prepayId", "appId", null, keyPair.getPrivate()); + } + + /** + * 测试getAppPayInfo方法的空值验证 - privateKey为null + */ + @Test(expectedExceptions = IllegalArgumentException.class, + expectedExceptionsMessageRegExp = "prepayId, appId, mchId 和 privateKey 不能为空") + public void testGetAppPayInfoWithNullPrivateKey() { + WxPayUnifiedOrderV3Result.getAppPayInfo("prepayId", "appId", "mchId", null); + } +} diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/WxSignQueryResultTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/WxSignQueryResultTest.java new file mode 100644 index 0000000000..52df2b6e2b --- /dev/null +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/WxSignQueryResultTest.java @@ -0,0 +1,125 @@ +package com.github.binarywang.wxpay.bean.result; + +import com.github.binarywang.wxpay.util.XmlConfig; +import org.testng.Assert; +import org.testng.annotations.Test; + +/** + * WxSignQueryResult 单元测试 + * + * @author Binary Wang + */ +public class WxSignQueryResultTest { + + /** + * 测试 XML 解析,特别是 contract_expired_time 字段 + */ + @Test + public void testFromXML() { + /* + * xml样例字符串来自于官方文档 + * https://pay.weixin.qq.com/doc/v2/merchant/4011987640 + */ + String xmlString = "
+ * 实名验证测试类. + *+ * + * @author Binary Wang + */ +@Test +@Guice(modules = ApiTestModule.class) +@Slf4j +public class RealNameServiceImplTest { + + @Inject + private WxPayService payService; + + /** + * 测试查询用户实名认证信息. + * + * @throws WxPayException the wx pay exception + */ + @Test + public void testQueryRealName() throws WxPayException { + RealNameRequest request = RealNameRequest.newBuilder() + .openid("oUpF8uMuAJO_M2pxb1Q9zNjWeS6o") + .build(); + + RealNameResult result = this.payService.getRealNameService().queryRealName(request); + log.info("实名认证查询结果:{}", result); + } + + /** + * 测试查询用户实名认证信息(简化方法). + * + * @throws WxPayException the wx pay exception + */ + @Test + public void testQueryRealNameSimple() throws WxPayException { + RealNameResult result = this.payService.getRealNameService() + .queryRealName("oUpF8uMuAJO_M2pxb1Q9zNjWeS6o"); + log.info("实名认证查询结果:{}", result); + } +} diff --git a/weixin-java-qidian/pom.xml b/weixin-java-qidian/pom.xml index 5135dea3c8..0752ce69d0 100644 --- a/weixin-java-qidian/pom.xml +++ b/weixin-java-qidian/pom.xml @@ -7,7 +7,7 @@
- * 默认接口实现类,使用apache httpclient实现 + * 默认接口实现类,使用apache httpClient 5实现 * Created by Binary Wang on 2017-5-27. ** * @author Binary Wang */ -public class WxQidianServiceImpl extends WxQidianServiceHttpClientImpl { +public class WxQidianServiceImpl extends WxQidianServiceHttpComponentsImpl { }